![]() |
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. |
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. |
All times are GMT +1. The time now is 10:27 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com