Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Conditional format macro
I have 20 columns in an Excel 2003 spreadsheet. I am not sure how many rows
there are as this could change. If Column D and Column E are NOT equal, I would like both the cells (colorIndex to be 40) to be tan If Column F and Column G are not equal then I would like to shade the cells tan as above. Similarly for Columns H and I. The last row has the word Grand Total in Col A and that the conditional formatting should not apply to that row. I know how to do this with conditional formatting but could someone please help me do this with a macro that I can install on my PC? I have to implement this formatting for several spreadsheets of various sizes and a macro would be much easier to use. Thanks. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Conditional format macro
Sub AddCF()
Dim iLastRow As Long iLastRow = Cells(Rows.Count, "A").End(xlUp).Row - 1 With Range("D1").Resize(iLastRow, 2) .FormatConditions.Delete .FormatConditions.Add Type:=xlExpression, _ Formula1:="=$D" & ActiveCell.Row & _ "<$E" & ActiveCell.Row .FormatConditions(1).Interior.ColorIndex = 40 End With End Sub -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Elaine" wrote in message ... I have 20 columns in an Excel 2003 spreadsheet. I am not sure how many rows there are as this could change. If Column D and Column E are NOT equal, I would like both the cells (colorIndex to be 40) to be tan If Column F and Column G are not equal then I would like to shade the cells tan as above. Similarly for Columns H and I. The last row has the word Grand Total in Col A and that the conditional formatting should not apply to that row. I know how to do this with conditional formatting but could someone please help me do this with a macro that I can install on my PC? I have to implement this formatting for several spreadsheets of various sizes and a macro would be much easier to use. Thanks. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Worksheet macro conditional format question | Excel Discussion (Misc queries) | |||
Conditional Format Macro fails to set interior color - HELP!!! | Excel Programming | |||
Conditional Format as a MACRO | Excel Worksheet Functions | |||
conditional format macro formula | Excel Programming | |||
conditional format macro not working - almost there | Excel Programming |