how to check if background color is yellow?

dee101

Active Member
Joined
Aug 21, 2004
Messages
282
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
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Is the background yellow because someone set it to yellow or is it yellow because of conditional formatting?
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,214,630
Messages
6,120,634
Members
448,973
Latest member
ChristineC

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top