Help fine tuning delete macro
Hi,
Try it like this
Sub DeleteCM()
lastrow = Cells(Rows.Count, "B").End(xlUp).Row
For x = lastrow To 2 Step -1
If UCase(Cells(x, 2)) = "CM" Or UCase(Cells(x, 2)) = _
"IC" Or UCase(Cells(x, 2)) = "MG" Then
Rows(x).EntireRow.Delete
End If
Next
End Sub
Mike
"mattg" wrote:
I'm trying to use this mcaro to delete rowsa based on the value of Column B
and it isn't working
Sub DeleteCM()
lastrow = Cells(Rows.Count, "B").End(xlUp).Row
Set myrange = Range("B2:B" & lastrow)
For Each Count In myrange
If Count.Value = "CM" Then
Count.EntireRow.Delete
End If
Next
End Sub
Any help would be appreciated.
BTW there are 2 other values I want to delete the rows if they exist "IC"
and "MG". Do I need 3 separate macros?
|