Excel Mitchell
New Member
- Joined
- Apr 12, 2012
- Messages
- 10
Hello, everyone.
I'm attempting to make a macro that will delete the row if specific multiple values exist anywhere in that row. I searched and found a formula which looks like it'll work. I've modified it but it's not working for me and gives me an error. Any assistance you can provide would be a big help.
I'm attempting to make a macro that will delete the row if specific multiple values exist anywhere in that row. I searched and found a formula which looks like it'll work. I've modified it but it's not working for me and gives me an error. Any assistance you can provide would be a big help.
VBA Code:
Sub quickDelete()
Application.ScreenUpdating = False
Dim rngFind As Range
Dim strValueToPick As String
Dim rngLook As Range
Dim strFirstAddress As String
Dim topRow As Long
Dim botRow As Long
Dim rf As Range
Dim rfa As String
Set rngLook = Range("A1:AA500000" & Cells(Rows.Count, 1).End(xlUp).Row)
strValueToPick = "A","B","C"
With rngLook
Set rngFind = .Find(strValueToPick, LookIn:=xlValues, lookat:=xlWhole)
If Not rngFind Is Nothing Then
strFirstAddress = rngFind.Address
Do
Set rf = rngFind
rfa = rngFind.Address
rngFind.EntireRow.Delete
Loop While Not rf Is Nothing And rfa <> strFirstAddress
End If
End With
Application.ScreenUpdating = True
End Sub