Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cell Backcolor in Excel 2000

Status
Not open for further replies.

snorky

Programmer
Jun 5, 2001
58
GB
Dear All,
I'm using Excel in Office 2000 and am writing a program in VBA that needs to check for a cell background to be Red or Yellow or Green. I tried using eg:

if Selection.Interior.colorindex = 4 then . . .

But this doesn't work - I had hoped you could just check for cell(x,y).backcolor= vbRed or similar...

Any clues ? ? ?

Thanx in advance

Snorky X-)

 
MORE INFO
The cells I'm trying to look at are having their backcolor changed by conditional formatting. When I look at the colorindex it is always "-4142". ????
 
Snorky ... the Selection.Interior.ColorIndex is on the right path ... if you post the bit of code that's causing the angst, we may be able to help more. You will also need to explain exactly what else is going on with the conditional formatting ... You may have a problem if you are using VBA and conditional formatting with the timing of the comparison as I can't find any reference to controlling the timing of C.F. .. it appears to be run-time equivalent. The only thing I would suggest is altering the timing of your comparison, so if you currently do it AFTER a calculation - too late! C.F. has already changed your cell color. Try a different event like "beforeupdate" ...

Hope this helps ...

Cheers,
Morry.
 
To get the background color applied by condition 1 for the selected cell you would use something like :

Selection.FormatConditions(1).Interior.ColorIndex

You can change the FormatConditions Index as appropriate

Acron

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top