+ Reply to Thread
Results 1 to 9 of 9

Excel 2007 : Changing row colour if column D date is before current system date

  1. #1
    Registered User
    Join Date
    08-22-2009
    Location
    Hastings, England
    MS-Off Ver
    Microsoft Office Excel 2007
    Posts
    4

    Changing row colour if column D date is before current system date

    Have a 'competitions entered' spreadsheet which contains a closing date for each competition in column D. I'd like a formula or macro which compares each date in column D and if the date is earlier than todays date format fill the background of that row to a grey colour.

    Would be grateful for any suggestions to achieve the above please.
    Last edited by trevor432990; 08-22-2009 at 11:44 AM. Reason: Exasperation

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Changing row colour if column D date is before current system date

    Use conditional formatting. Let's say the columns of data are A:M starting at row 2.

    1) Highlight A2:M200 (or however many rows down you want)
    2) Click Format > Conditional Formatting (or whatever the equivalent Excel 2007 to open the CF window)
    3) Use Condition1: Formula Is: =AND($D2>0,TODAY()>$D2)
    4) Use Format... Patterns... Grey color
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    08-22-2009
    Location
    Hastings, England
    MS-Off Ver
    Microsoft Office Excel 2007
    Posts
    4

    Re: Changing row colour if column D date is before current system date

    Many thanks JB that worked a treat (see attachment). Out of interest is there a way of carrying out this formatting for the whole worksheet automatically without having to manually select rows each time I add new ones?
    Last edited by trevor432990; 08-22-2009 at 08:53 AM. Reason: remove data

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Changing row colour if column D date is before current system date

    As demonstrated in my instructions above, you should select the entire range at once and fill out the formula based on the active row (the primary row that is shown as the first row you selected when you chose the whole range).

    In my instructions, if you started and A2 and highlighted all the data through M200, row 2 is still the primary row, so the formula should be entered as shown. By using a $D you are locking the column to column D for all rows, but by not using a $ in front of the 2 in $D2, that leaves the row reference relative and it will adjust automatically down the whole data set.

    Follow those instructions above explicitly. You do not need to do this row by row.

  5. #5
    Registered User
    Join Date
    08-22-2009
    Location
    Hastings, England
    MS-Off Ver
    Microsoft Office Excel 2007
    Posts
    4

    Re: Changing row colour if column D date is before current system date

    Thanks again JB (excuse my ignorance) so are you saying the formula you gave me already will work without me having to select all the rows in a worksheet? If not can you detail what the formula should be please.

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Changing row colour if column D date is before current system date

    Trevor, follow the instructions given above TO THE LETTER. My example indicates selecting 200 rows of data to apply the formula to all at once. Surely you see that?

    I do not recommend you apply any conditional formatting to your entire sheet, to use your words. Select a number of rows sufficient for your needs, 1000s of rows even, just not all of them!

    Then use the formula given. You should only have to apply the formula ONCE for the entire range of rows you select. You will select a lot of rows, just do it.

    1) Highlight A2:M200 (or however many rows/columns you want)
    2) Click Format > Conditional Formatting (or whatever the equivalent Excel 2007 to open the CF window)
    3) Use Condition1: Formula Is: =AND($D2>0,TODAY()>$D2)
    4) Use Format... Patterns... Grey color

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Changing row colour if column D date is before current system date

    An alternate method would be to highlight a row you've already successfully formatted, click on the FORMAT PAINTER icon, and then select all the other rows to paint that formatting into.

  8. #8
    Registered User
    Join Date
    08-22-2009
    Location
    Hastings, England
    MS-Off Ver
    Microsoft Office Excel 2007
    Posts
    4

    Re: Changing row colour if column D date is before current system date

    I hope all forum gurus are not as touchy as you. Thanks for the advice again anyway.

  9. #9
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Changing row colour if column D date is before current system date

    (chuckle) It is very simple to miss pieces of steps, do it myself all the time, so being emphatically pointed back to the original instructions is a legitimate response, yes?

    It is also not uncommon to get questions that basically equate to, "I didn't fully try what you told me yet, but will this work?" Again, I've caught myself doing that very thing.

    So, obnoxious tips of the day:
    1) Be meticulous when someone provides step-by-step instructions
    2) Be sure to fully try the suggested solution before pulling apart the method as suspect.

    I know this works, so I hope you got it working, if not with the first method, then by the alternate method suggested in post #7.

    As you can see, above all else, I am trying to make sure you get the results you want.

    If that takes care of your need, be sure to EDIT your original post, click Go Advanced and mark the PREFIX box [SOLVED].

+ 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