Robdiqulous
New Member
- Joined
- Sep 11, 2017
- Messages
- 15
I am trying to delete a row if it HAS a red color in Column C AND if it DOESN'T have the words PO box in Column N. I have gotten it to where it deletes the rows that DO have po box in N but I can't seem to get it to go the other way and KEEP the rows with po box. Here is my code. The 13551615 is the red background color.
Also if there is a faster way to do this that would be great too. This takes about 13 seconds to run through my 3k rows. I only have like 20 rows with the color in them and I already sort those to the top. But I really just want this to work even if it takes a second.
Also if there is a faster way to do this that would be great too. This takes about 13 seconds to run through my 3k rows. I only have like 20 rows with the color in them and I already sort those to the top. But I really just want this to work even if it takes a second.
Code:
Dim lngRow As Long
Dim lngRows As Long
'Find the last row in Column A
lngRows = Range("A" & Rows.Count).End(xlUp).Row
For lngRow = lngRows To 2 Step -1
If ActiveWorkbook.Worksheets("Sheet1").Cells(lngRow, "C").FormatConditions(1).Interior.Color = 13551615 Then
If Not InStr(1, LCase(Range("N" & lngRow)), LCase("PO Box")) <> 0 Then
ActiveWorkbook.Worksheets("Sheet1").Rows(lngRow).EntireRow.Delete
End If
End If
Next