View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Peter T[_5_] Peter T[_5_] is offline
external usenet poster
 
Posts: 84
Default alternate rowshading using conditional format excel 2007/2010

If you want something that'll be compatible with 2003/2007, instead of
ColorIndex apply an valid color-value to the Color property, eg
..FormatConditions(1).Interior.Color = RGB(255,255,0) ' eg yellow

In 2003 the RGB colour will map to the closest in the 56 colour palette.

or you could in theory do
..FormatConditions(1).Interior.Color = wb.colors(6)
where wb refers to the workbook and 6 is a colorindex 1-56.

However if you're only using 2007/2010 it's normally better to use the new
Tables and Table Styles for alternate row shading

Regards,
Peter T


"Ludo" wrote in message
...
Hi,

I'm using following code on a Excel 2003 version without problems to
change the row shading.
Formula comes from John Walkenbachs site see:
http://spreadsheetpage.com/index.php...al_formatting/
The code comes from the macro recorder from Excel 2003:

Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression,
Formula1:="=MOD(ROW();2)=0"
Selection.FormatConditions(1).Interior.ColorIndex = intColorIndex

where intColorIndex is a number from 1 to 56.

But this isn't working anymore in Excel 2007!

Anyone knowing how to code it for Excel 2007/2010?

Thanks in advance.
Ludo