+ Reply to Thread
Results 1 to 5 of 5

Changing Color Font based on date/time column

  1. #1
    Registered User
    Join Date
    12-19-2012
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2007
    Posts
    2

    Changing Color Font based on date/time column

    Hi,
    I need some help with a macro and I’m not very proficient in visual basic

    What I want to do is change the font color each time the date/time row changes.

    Column A3 has date/ time is in that column

    I want to change the font color for Range A3:H3 to red

    Then in the next row (A4:H4) change it to red if the date / time in A4 is the same as A3, but if it is higher by 30 minutes change it to another color. This continues down another 30 rows (A?:H?) or so until no more data in Time / date column.

    I could not figure out how to do this in the conditional formatting manager so I turned to a simple macro that isn’t so simple for me.

    Thanks,

    Mike
    Last edited by greymoore; 12-19-2012 at 03:40 PM.

  2. #2
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Changing Color Font based on date/time column

    Is date reference always cell A3 or is it the cell before the one evaluated? Like A4 is compared to A3 but A5 will be compared to A4, etc.
    Below is a workbook with dates in column A and conditional formatting as per your request. I hope!
    If this works for you, you might just have to extend the range the conditional formatting applies to.
    Look at the range of cells the conditional formatting applies to and you'll see it goes up to column ZZ. Change this to suit your needs. Change this to both conditions.
    Regards
    Attached Files Attached Files
    Last edited by p24leclerc; 12-19-2012 at 06:12 PM.
    Pierre Leclerc
    _______________________________________________________

    If you like the help you got,
    Click on the STAR "Add reputation" icon at the bottom.

  3. #3
    Registered User
    Join Date
    12-19-2012
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Changing Color Font based on date/time column

    Thanks for the reply. Not quite what I need. I tried this also, but couldn't figure how to get the date/time with exact date/time to have the same font color formatting without making a rule for every minute of the day. Check out the attached file of what the data looks like before a macro or conditional formatting and what I want the finish to look like. Column a contains the date/time which will always be sorted the earliest to the latest. The font color formatting can repeat every 7 or 8 colors but I was going to stay away from yellow since it is hard to see.

    Thanks,
    Mike
    Attached Files Attached Files

  4. #4
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Changing Color Font based on date/time column

    Now that I understand what you want to do, here is a macro that should do it.
    I'll let you play with the RGB values to get the colors you want. You can change the number of color by changing the C_olor array parameters.
    Attached Files Attached Files
    Last edited by p24leclerc; 12-19-2012 at 09:20 PM.

  5. #5
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Changing Color Font based on date/time column

    You might find it easier to use ColorIndex instead of RGB. So here is the modification to the macro:
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    12-19-2012
    Location
    Pittsburgh, PA
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Changing Color Font based on date/time column

    Pierre,

    Excellent! Thank you very much. Just what I was looking to do.

    Mike

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1