MrExcel Publishing
Your One Stop for Excel Tips & Solutions

test for formatting in VBA

Posted by Wiggy on January 20, 2002 3:57 AM

I have set up the Gant Chart as a staff rots sheet
Great Conditional Formatting etc looks next task!
Iwant to automatically insert .5 hours in each columb that is formatted to add up worked hours each half hour.
This helps us link peak times with staff numbers.
I want to test for say yellow fill and auto insert .5
This is my dificulty testing for the fill color
Anyone Help ??
Barry or Wiggy

Posted by Damon Ostrander on January 21, 2002 10:41 AM

Hi Wiggy,

You can test a cell's fill color as follows:

If [B4].Interior.ColorIndex = 6 then [B4] = 0.5

where [B4] is a range reference to cell B4, but can be changed to any cell range reference. I think 6 is the yellow color index value.