Check interior colorindex of a cell - with a twist

  • Thread starter Thread starter MaxLamer
  • Start date Start date
M

MaxLamer

Hi evrybodri!

I have the following issue: when quring the color of a cell with:

MsgBox (ActiveCell.Interior.ColorIndex)

the result is -4142 if the cell is not formatted with any color.

Now if I apply conditional formatting to the same cell, and due to th
result the cell is shown red, the VBA code still gives a result o
-4142 instead of 3 for red.

What is the propoerty of the cell, which gives the actual color of th
cell, as shown on the screen?


Thx ahead,

M@
 
Conditional formatting doesn't change the interior color index of a cell.
Your code would work as you expect if you color the cell using the paint
tool off the formatting tool bar
or if you use code....

With Selection
.Interior.ColorIndex = vbRed
MsgBox (.Interior.ColorIndex)
End With
 

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