I'm trying to create a macro to msgbox all cells with red fill on when opening a spreadsheet, I currently have the below but it's not even displaying a msgbox, any ideas?
Sub test()
Dim ws As Worksheet
Set ws = Sheets("Month End Tasks")
Dim i As Integer
i = 1
Do Until i = 11
If ws.Range("C" & i).Interior.Color = RGB(255, 0, 0) Then
MsgBox "C" & i & " is red!!"
End If
i = i + 1
Loop
End Sub
Thanks,
Try to see the RGB colors of the C1 to C11, using the following:
It would print a summary of the RGB colors in the immediate window. Like this:
An easier method is simpy to select the cell with the color and to press
Format Cells>Patterns>Colors>Custom:
Then the RGB values are visible.
Concerning the conditional formatting, it is probably the best to apply the same logic as in the condition: Excel 2007 conditional formatting - how to get cell color?