Hello all
I am trying to find some VBA code to delete rows that match a criteria but the criteria and column to search can change
I would like a popup box to ask for the criteria, then ask what column to search in
Then delete all the rows that match that criteria
I have tried to put this together but its not correct
Sub RemoveCritera()
Dim c As String
Dim d As String
Dim LastRow As Long
Dim x As Long
Application.ScreenUpdating = False
d = InputBox("Enter column letter", "Remove Duplicates", "A")
c = InputBox("Criteria", "Delete matches", "Criteria")
If c = "" Then Exit Sub
LastRow = Range(d & Rows.Count).End(xlUp).Row
For x = LastRow To 1 Step -1
If Application.WorksheetFunction.CountIf(Range(c & "1:" & c & x), Range(c & x).Text) > 0 Then
Range("A" & x).EntireRow.Delete
End If
Next x
Application.ScreenUpdating = True
End Sub
Can someone please help on this
I am trying to find some VBA code to delete rows that match a criteria but the criteria and column to search can change
I would like a popup box to ask for the criteria, then ask what column to search in
Then delete all the rows that match that criteria
I have tried to put this together but its not correct
Sub RemoveCritera()
Dim c As String
Dim d As String
Dim LastRow As Long
Dim x As Long
Application.ScreenUpdating = False
d = InputBox("Enter column letter", "Remove Duplicates", "A")
c = InputBox("Criteria", "Delete matches", "Criteria")
If c = "" Then Exit Sub
LastRow = Range(d & Rows.Count).End(xlUp).Row
For x = LastRow To 1 Step -1
If Application.WorksheetFunction.CountIf(Range(c & "1:" & c & x), Range(c & x).Text) > 0 Then
Range("A" & x).EntireRow.Delete
End If
Next x
Application.ScreenUpdating = True
End Sub
Can someone please help on this