Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 106
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Worksheet macro conditional format question Dingy101 Excel Discussion (Misc queries) 3 June 8th 09 07:54 PM
Conditional Format Macro fails to set interior color - HELP!!! bttman Excel Programming 0 April 1st 06 02:22 AM
Conditional Format as a MACRO Gunjani Excel Worksheet Functions 3 March 29th 06 05:22 PM
conditional format macro formula Todd Excel Programming 1 March 20th 06 05:30 PM
conditional format macro not working - almost there Naz Excel Programming 3 December 9th 05 09:53 PM


All times are GMT +1. The time now is 02:59 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"