sofiarashid
03-14-2017, 08:15 AM
Hi
I'm hoping someone can help me.
In Sheet 1 I have created a command button. I am trying to look at sheet named "Report", go to Col AS and for any cells all the way to the bottom of the report that contain "2-WAY" I want it to delete entire rows. I have written the below;
Private Sub CommandButton21_Click()
With Worksheets("Report").Activate
With Range("A1" & Range("AS" & Rows.Count).End(xlUp))
.AutoFilter Field:=45, Criteria1:="2 - WAY"
On Error Resume Next
.Offset(1).SpecialCells(12).EntireRow.Delete
End With
.AutoFilterMode = False
End With
End Sub
I am getting error Run-time error 1004 - and the above text in red is highlighted in yellow. I have tried a few different suggestions on the net but nothing seems to work.
Also, to add that this command works if the command button is on the same sheet!
Please help!
Thanks in advance :)
I'm hoping someone can help me.
In Sheet 1 I have created a command button. I am trying to look at sheet named "Report", go to Col AS and for any cells all the way to the bottom of the report that contain "2-WAY" I want it to delete entire rows. I have written the below;
Private Sub CommandButton21_Click()
With Worksheets("Report").Activate
With Range("A1" & Range("AS" & Rows.Count).End(xlUp))
.AutoFilter Field:=45, Criteria1:="2 - WAY"
On Error Resume Next
.Offset(1).SpecialCells(12).EntireRow.Delete
End With
.AutoFilterMode = False
End With
End Sub
I am getting error Run-time error 1004 - and the above text in red is highlighted in yellow. I have tried a few different suggestions on the net but nothing seems to work.
Also, to add that this command works if the command button is on the same sheet!
Please help!
Thanks in advance :)