email = Application.match("email", Range("1:1"), 0)
finalrow = Cells(Rows.Count, 1).End(xlUp).Row
For counter3 = finalrow To 1 Step -1
If Cells(counter3, email).Interior.ColorIndex <> RGB(255, 0, 0) Then
Rows(counter3).Delete
End If
Next counter3
Hi Bob,
Use DisplayFormat.Interior.Color to get the color set by CF e.g.
Debug.Print Range("A1").DisplayFormat.Interior.Color
see attached file for some examples with CF rules set.
Regards
Phil
Thanks very much Phil. If you don't mind, can you please explain a bit about what "debug.print" is used for? I have tried to read about and understand that but I just cannot seem to figure it out.
Regards,
Bob Kaplan
Hi Bob,
Debug.Print prints information to the Immediate Window in the VBA Editor/Debugger. So Debug.Print Range("A1").DisplayFormat.Interior.Color prints the value of the DisplayFormat Interior Color of A1.
You can read about debugging and Debug.Print here
Regards
Phil
Hi Phil,
I just cannot get this to work. Maybe, I didn't input your suggestion correctly? When I run this macro it deletes ALL rows regardless of the color of the cell in column #3.
Can you please review and let me know where I'm going wrong?
Thanks,
Bob
Hi Bob,
Please attach your file for me to check.
Thanks
Phil
Whoops....I meant to. Here it is.
Just had a quick check and i think it is a combination of missing the displayformat & using colorindex rather than color
This deletes the red cells
Cells(counter3, email).DisplayFormat.Interior.Color = RGB(255, 0, 0)
but you had
Cells(counter3, email).Interior.ColorIndex = RGB(255, 0, 0)
Thanks. I will try that.