Consulting

Results 1 to 3 of 3

Thread: calender where the date colors change

  1. #1

    calender where the date colors change

    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

  2. #2
    VBAX Regular
    Joined
    Nov 2008
    Posts
    58
    Location
    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.
    [VBA]

    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
    [/VBA]

    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

  3. #3

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •