![]() |
Conditional Row Colours
Hi
I'm looking for a VBA script to colour all the cells in a row (or even just some in a row) a certain colour dependent on the value in the 'A' column cell. For instance, if cell A1 is Jan-03 then the whole row should be coloured light yellow (or whatever the RGB equivalent is); if cell A2 is Feb-03 then the whole row should be coloured light green; and so on... Is this possible? Thanks for you help. Rob |
Conditional Row Colours
For up to 3 colors you would use Conditional Formatting,
no VBA code involved. http://www.mvps.org/dmcritchie/excel/condfmt.htm For more than 3 colors as I think you have, and specifically because you asked for VBA see http://www.mvps.org/dmcritchie/excel/event.htm#case --- HTH, David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001] My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm Search Page: http://www.mvps.org/dmcritchie/excel/search.htm "Rob" wrote in message ... Hi I'm looking for a VBA script to colour all the cells in a row (or even just some in a row) a certain colour dependent on the value in the 'A' column cell. For instance, if cell A1 is Jan-03 then the whole row should be coloured light yellow (or whatever the RGB equivalent is); if cell A2 is Feb-03 then the whole row should be coloured light green; and so on... Is this possible? Thanks for you help. Rob |
Conditional Row Colours
Rob,
Select all the rows Goto menu formatConditional Formatting Change Condition 1 to Formula Is Add a formula of =$A1=DATE(2003,1,1) Click Format Select the Patterens tab, choose the colour OKI Click Add Change Condition 2 to Formula Is etc. OK -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "Rob" wrote in message ... Hi I'm looking for a VBA script to colour all the cells in a row (or even just some in a row) a certain colour dependent on the value in the 'A' column cell. For instance, if cell A1 is Jan-03 then the whole row should be coloured light yellow (or whatever the RGB equivalent is); if cell A2 is Feb-03 then the whole row should be coloured light green; and so on... Is this possible? Thanks for you help. Rob |
Conditional Row Colours
Rob,
Sub testit() Dim i As Long, lngLastRow As Long With Sheet1 lngLastRow = .Cells(Rows.Count, 1).End(xlUp).Row For i = 1 To lngLastRow Select Case .Cells(i, 1) Case CDate("1-Jan-03"): .Rows(i).Interior.ColorIndex = 36 Case CDate("1-Feb-03"): .Rows(i).Interior.ColorIndex = 35 End Select Next End With End Sub Rob "Rob" wrote in message ... Hi I'm looking for a VBA script to colour all the cells in a row (or even just some in a row) a certain colour dependent on the value in the 'A' column cell. For instance, if cell A1 is Jan-03 then the whole row should be coloured light yellow (or whatever the RGB equivalent is); if cell A2 is Feb-03 then the whole row should be coloured light green; and so on... Is this possible? Thanks for you help. Rob |
All times are GMT +1. The time now is 09:10 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com