Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Rob Rob is offline
external usenet poster
 
Posts: 234
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 691
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default 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



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
Conditional Formatting / Cell Fill Colours Coxy19 New Users to Excel 2 November 17th 08 07:57 PM
how do i get more than 3 colours in conditional formatting Nicole Excel Discussion (Misc queries) 7 April 24th 08 03:50 PM
colours missing in conditional formatting. Toobi-Won Kenobi[_2_] Excel Worksheet Functions 4 May 3rd 07 08:36 AM
Conditional Formatting with Colours / Colors [email protected] Excel Worksheet Functions 8 November 18th 06 08:29 PM
is it possible to have more than 3 colours in conditional format stevie Excel Worksheet Functions 1 October 23rd 05 09:53 PM


All times are GMT +1. The time now is 12:27 PM.

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"