ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Checking Cell Background Color (https://www.excelbanter.com/excel-programming/308374-checking-cell-background-color.html)

Doug Snow

Checking Cell Background Color
 
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...

Tom Ogilvy

Checking Cell Background Color
 
That looks correct:

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

is the correct test.

--
Regards,
Tom Ogilvy

"Doug Snow" wrote in message
om...
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...





All times are GMT +1. The time now is 05:58 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com