Hi all,
So I have a macro that removes unnecessary rows of data via a user prompt (probably snagged from a thread on here!), but I’d prefer to list the criteria of the items I need to remove in the macro since the criteria will not change. I think my biggest hurdle is my criteria data is in two different columns, not one. I.e. I have rows that have a type of "exam" or "web", once those are removed, I need to remove rows with a code that ends in a number (100,110,120, etc). I’ve thought of putting my criteria into a vlookup and leveraging an if statement but I just wasn’t sure which way is better to go about it. Any constructive input appreciated - thanks
So I have a macro that removes unnecessary rows of data via a user prompt (probably snagged from a thread on here!), but I’d prefer to list the criteria of the items I need to remove in the macro since the criteria will not change. I think my biggest hurdle is my criteria data is in two different columns, not one. I.e. I have rows that have a type of "exam" or "web", once those are removed, I need to remove rows with a code that ends in a number (100,110,120, etc). I’ve thought of putting my criteria into a vlookup and leveraging an if statement but I just wasn’t sure which way is better to go about it. Any constructive input appreciated - thanks
Code:
Sub DeleteRows()
Application.ScreenUpdating = False
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
Dim c As Range
Dim SrchRng As Range
Dim SrchStr As String
Set SrchRng = ActiveSheet.Range("myData", ActiveSheet.Range("A65536").End(xlUp))
SrchStr = InputBox("Please Enter A Search String")
Do
Set c = SrchRng.Find(SrchStr, LookIn:=xlValues)
If Not c Is Nothing Then c.EntireRow.Delete
Loop While Not c Is Nothing
Application.ScreenUpdating = True
Application.EnableEvents = True
Application.Calculation = xlCalculationAutomatic
If Err.Number <> 0 Then MsgBox "Errors occurred"
End Sub