Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 65
Default Colour a row, based on a cell value

Thanks Gord

Duncs

On Jan 27, 7:11*pm, Gord Dibben <gorddibbATshawDOTca wrote:
Fill color in B to H based on date in B?

Sub Color_Dates()
* * Dim rWhere As Range
* * Dim rCell As Range
* * Dim rcols As Range
* * Dim n As Long
* * Set rWhere = Range("B1:B100")
* * For Each rCell In rWhere
* * * * n = rCell.Row
* * * * Set rcols = Range("B" & n & ":H" & n)
* * * * Select Case rCell.Value
* * * * Case Is <= Date - 14
* * * * * * rcols.Interior.Color = 192 * *'red
* * * * Case Is <= Date - 7
* * * * * * rcols.Interior.Color = 49407 * *'orange
* * * * Case Is <= Date
* * * * * * rcols.Interior.Color = 5296274 * *'green
* * * * End Select
* * Next rCell
End Sub

Gord Dibben *MS Excel MVP

On Wed, 27 Jan 2010 01:19:50 -0800 (PST), Duncs
wrote:



Just one other thing...supposing that I wanted to colour in the cells
from column B to G, based on the value held in cell G(row num), how
would I do this?


I tried creating a new 'Range' variable and using this to assign the
row range of cells that I want to be filled in however, I can't figure
a way of assigning a row range, for example B5:H5, prior to colouring
in the cells.


Anyone help?


Duncs


On Jan 18, 11:37*am, chg wrote:
Sub Color_Dates()
* Dim rWhere As Range
* Dim rCell As Range
* Set rWhere = Range("B1:B100")


* For Each rCell In rWhere
* * Select Case rCell.Value
* * Case Is <= Date - 14
* * * * rCell.Interior.Color = 192 'red
* * Case Is <= Date - 7
* * * * rCell.Interior.Color = 49407 'orange
* * Case Is <= Date
* * * * rCell.Interior.Color = 5296274 'green
* * End Select
* Next


End Sub- Hide quoted text -


- Show quoted text -


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
Calculations based on cell colour Fred[_8_] Excel Discussion (Misc queries) 9 October 3rd 11 09:30 PM
Condition based on cell colour Richhall Excel Worksheet Functions 2 March 25th 07 04:23 PM
change current cell colour based on the value of adjacent cell on other worksheet Rits Excel Programming 2 November 23rd 06 11:57 AM
How do I set a colour to 4 cells based on the value of a cell Andy64 Excel Discussion (Misc queries) 1 September 6th 05 06:46 PM
Conditional Format with VBA - Interior Colour of cell based on value from in-cell dropdown Steve[_52_] Excel Programming 5 June 15th 04 11:45 AM


All times are GMT +1. The time now is 05:36 AM.

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

About Us

"It's about Microsoft Excel"