beartooth91
Board Regular
- Joined
- Dec 15, 2024
- Messages
- 66
- Office Version
- 365
- 2019
- 2016
- Platform
- Windows
I'm pretty sure this is a simple oversight, but I can't seem to figure it out:
I have a worksheet with data from B11:BO and to about row 100 (though it varies)
The code below is supposed to loop through and delete rows with the highlighted B cell color.
It kind of works....meaning when I run it; it deletes some of them and it takes me running the procedure another 3-4 times to get all of them.
I have a worksheet with data from B11:BO and to about row 100 (though it varies)
The code below is supposed to loop through and delete rows with the highlighted B cell color.
It kind of works....meaning when I run it; it deletes some of them and it takes me running the procedure another 3-4 times to get all of them.
VBA Code:
Sub Delete_NA_Points()
'
'Define Variables----------------------------
Dim lr As Long, cell As Range
'--------------------------------------------
With Sheets(1)
lr = .Cells(Rows.Count, "B").End(xlUp).Row
For Each cell In .Range("B11:B" & lr)
If cell.Interior.ColorIndex = 22 Then
cell.EntireRow.Delete
End If
Next cell
End With
End Sub