VBA loop to delete entire row if cells contain a particular string - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

VBA loop to delete entire row if cells contain a particular string

bennyblancobennyblanco Posts: 5Member
Hello,

I need code to go through cells of a column of unknown length and delete the entire row if the cells contain a particular string ("--"). This is what I have so far, but it does not work. Can anyone help? I can't program.

Dim RowKdx As Long
For RowKdx = Range("b1").End(xlDown).Row To 2 Step -1
Do While Cells(RowKdx, "b").Value <> ""
If InStr(RowKdx, "--") = 1 Then
Rows(RowKdx).Delete
End If
RowKdx = RowKdx - 1
If RowKdx = 1 Then Exit For
Loop
Next RowKdx

Sign In or Register to comment.