PDA

View Full Version : calender where the date colors change



anon125
09-07-2009, 01:27 PM
I have an excel 2002 file with a calender in it.
above it are 8 date ranges.
i need the calender dates to be different colors depending on which date range they fall within.
any ideas folks?
thanks

tammyl
10-06-2009, 05:56 AM
Hi,

I haven't tested this but it may give you some starting points.

You will need to change the cell references, etc to match you spreadsheet.


Set CalRng = Range("A21:G54") "your calendar ranges"
Set EnDate = "your cell reference for end date"
Set StDate = "your cell reference for start date"

For Each c In CalRng
c.Select
'Test if cell blank
If c <> "" Then
'Test if cell > End Date to exit for/each to goto next row
If c > EnDate Then
Exit For
Else
'Test if the cell value is >=Start Date and <= End Date
If c >= StDate And c <= EnDate Then
c.Interior.ColorIndex = "your index colour code"
End If
End If
End If
Next c
Next iRow


This is my first reply on this forum and i'm no vba expert, so please keep that in mind but i do hope this helps. Someone may have a better option for you.

Cheers Tammy

anon125
10-10-2009, 12:18 PM
http://www.vbaexpress.com/forum/showthread.php?p=196498#post196498
to see final result. thanks