how to check if background color is yellow?

dee101

Active Member
Joined
Aug 21, 2004
Messages
261
I want to check a range and see if the interior color is yellow, and if so let me know which cell or cells it is, something like this

If range("A4:A8, A12:A16,A20:A24,A28:A32").Interior.coler = 6 then let me know what cells are yellow
 

Some videos you may like

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

Ruddles

Well-known Member
Joined
Aug 24, 2010
Messages
5,785
Is the background yellow because someone set it to yellow or is it yellow because of conditional formatting?
 

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Try

Code:
Sub Yeller()
Dim c As Range
Dim msg As String
For Each c In Range("A4:A8,A12:A16,A20:A24,A28:A32")
    If c.Interior.ColorIndex = 6 Then msg = msg & c.Address(False, False) & ", "
Next c
If msg <> "" Then MsgBox Left(msg, Len(msg) - 2), vbInformation, "Yellow cells"
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,108,624
Messages
5,523,963
Members
409,547
Latest member
AW2020

This Week's Hot Topics

Top