Checking Cell Background Color

  • Thread starter Thread starter Doug Snow
  • Start date Start date
D

Doug Snow

I am trying to write a nested If statement based on the background
color in a cell...

Some cells (not all) have either a Light Yellow or Red background on
the worksheet that I will begin to maintain. If the background color
is x, I want this option button set, if the background color is y,
this option button gets set.

Set PNList = .Cells.Find(what:=FindPN, LookIn:=xlValues,
lookat:=xlWhole, searchorder:=xlByRows)

This is after it searches from a set pnlist = .cells.find instruction
(where PNList is a range).

If .Cells(PNList.Row, 1).Font.ColorIndex = 3 Then
ckbRedText.Value = True
ElseIf .Cells(PNList.Row, 1).Interior.ColorIndex = 19 Then
optCURR.Value = True
ElseIf .Cells(PNList.Row, 1).Interior.ColorIndex = 3 Then
optOLD.Value = True

End If

The .Cells(PNList.Row, 1).Font.ColorIndex = 3 command works just fine;
just cant figure it out when its the cell background color I am
looking at...
 
That looks correct:

Range("A1").Interior.ColorIndex = 19

is the correct test.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top