jvenning
11-25-2008, 06:00 PM
Hi everyone. Here's my situation.
I have a sheet that contains details of car parts - each part per row. The first column has the part no. of the part in. I would like to have a delete function that when the user clicks on a button, a prompt would show asking for the part no. of the row to be deleted.
I have the following code but I get an 'Identifier under cursor is not recognized' error when running it:
Private Sub CommandButton1_Click()
Set Sheet = book.Worksheets("Parts")
XL.Visible = True
Sheet.Activate
strToFind = InputBox("Enter Part No.")
Set Rng = Sheet.Range("A:A")
Set toDel = Rng.Find(strToFind)
If Not toDel Is Nothing Then
Sheet.Rows(toDel.Row).Delete
Else
Wscript.Echo "Selection not valid"
End If
End Sub
I have tried many codes before but the script would be launched from a different worksheet - most of the codes I have used before contained 'Activeworksheet' thus wont delete the data on a seperate worksheet.
Any help is much appreciated.
Regards,
J.Venning
I have a sheet that contains details of car parts - each part per row. The first column has the part no. of the part in. I would like to have a delete function that when the user clicks on a button, a prompt would show asking for the part no. of the row to be deleted.
I have the following code but I get an 'Identifier under cursor is not recognized' error when running it:
Private Sub CommandButton1_Click()
Set Sheet = book.Worksheets("Parts")
XL.Visible = True
Sheet.Activate
strToFind = InputBox("Enter Part No.")
Set Rng = Sheet.Range("A:A")
Set toDel = Rng.Find(strToFind)
If Not toDel Is Nothing Then
Sheet.Rows(toDel.Row).Delete
Else
Wscript.Echo "Selection not valid"
End If
End Sub
I have tried many codes before but the script would be launched from a different worksheet - most of the codes I have used before contained 'Activeworksheet' thus wont delete the data on a seperate worksheet.
Any help is much appreciated.
Regards,
J.Venning