Hi All
I need to delete some rows which are not equal to certain text including wildcard as words can be attached with other text as well. However the macro doesn't work, please could anyone help? Thanks.
I need to delete some rows which are not equal to certain text including wildcard as words can be attached with other text as well. However the macro doesn't work, please could anyone help? Thanks.
VBA Code:
Private Sub RemoveRows()
Sheet1.Select
Dim x As Long, LastRow As Long
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
Range("B:B").Delete
For x = LastRow To 2 Step -1
If Cells(x, 2).Value <> "*Apple*" And Cells(x, 2).Value <> "*Orange*" And Cells(x, 2).Value <> "*Banana*" Then
Rows(x).Delete
End If
Next x
End Sub