Hi,
I'm looking to create a macro where someone could enter a column and a value and all rows that contain that value in that column will be erased. I was browsing old posts on this board and I found something that looks good but has one fatal error. Here's the code:
This works well, unless my value is 0 which comes up a lot. If I enter say column V and value 0 It deletes rows at random instead of just the rows that contain 0. That is not good. Any ideas how to fix this?
I'm looking to create a macro where someone could enter a column and a value and all rows that contain that value in that column will be erased. I was browsing old posts on this board and I found something that looks good but has one fatal error. Here's the code:
Code:
Sub myDeleteRows()
Dim MyCol As String
Dim MyVal As Variant
Dim i As Integer
MyCol = InputBox("column to look through", "Column Search", "A")
MyVal = InputBox("Value to look for", "search value", 0)
For i = 1 To Range(MyCol & "65536").End(xlUp).Row Step 1
If Application.WorksheetFunction.CountIf(Range("A" & i & ":AZ" & i), MyVal) > 0 Then
Range("A" & i).EntireRow.Delete
End If
Next i
End Sub