Hi everyone,
I'm fairly new to macros as a whole. (Hence I've been coming here a lot for some help) And I've been trying to figure out a macro on my own that would delete an entire row of data in if the text "Ad" is populated into any cell in column B.
Here is the code I have so far:
I have a feeling it has something to do with the ".Entire.Row.Delete" but I'm stumped
can someone help me out?
thanks,
~Mike
I'm fairly new to macros as a whole. (Hence I've been coming here a lot for some help) And I've been trying to figure out a macro on my own that would delete an entire row of data in if the text "Ad" is populated into any cell in column B.
Here is the code I have so far:
Code:
Sub Delete_Ads_Rows()
Dim rng As Range
Dim cel As Range
With Worksheets("NSB")
r = .Cells(.Rows.count, 2).End(xlUp).Row
Set rng = .Range(.Cells(2, 2), .Cells(r, 2))
For Each cel In rng.Cells
If cel.Value = "Ad" Then
.Cells(cel.Row, 2).Entire.Row.Delete
End If
Next cel
End With
End Sub
I have a feeling it has something to do with the ".Entire.Row.Delete" but I'm stumped
thanks,
~Mike