I'm pretty new to VBA, but I am having problems getting a macro to delete any rows. I have a command button, with the following code:
Private Sub CommandButton4_Click()
' Delete a record
Set MySheet = Worksheets("Sheet1"
MySheet.Range("A2:E2".Delete Shift:=xlUp
End Sub
However when I use it, I get a 'delete object failed in range class' error. Also, could somebody explain how you use to 'Selection' object to group rows. For example, I have a list of rows, and I want to select them all, before applying a delete?
Thanks for the help!
Private Sub CommandButton4_Click()
' Delete a record
Set MySheet = Worksheets("Sheet1"
MySheet.Range("A2:E2".Delete Shift:=xlUp
End Sub
However when I use it, I get a 'delete object failed in range class' error. Also, could somebody explain how you use to 'Selection' object to group rows. For example, I have a list of rows, and I want to select them all, before applying a delete?
Thanks for the help!