+ Reply to Thread
Results 1 to 11 of 11

conditional formatting - dates

  1. #1
    Registered User
    Join Date
    12-15-2006
    Posts
    25

    conditional formatting - dates

    I have a list of actual dates against a list of planned dates.
    I want to highlight those actual dates that occur in the month after the planned date.

    For example, if the planned date is 15 April and the actual date is 28 April - no highlight - BUT if the actual date is 1 May - then it highlights.

    Thanks!

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Select the range of Actual Dates....and go to Format|Conditional Formatting.

    Assuming the Planned dates are in A1:A100 and the Actual dates are in B1:B100,

    then in the CF window, select Formula Is from 1st drop down and enter formula:

    =MONTH(B1)>MONTH(A1) where A1 and B1 contain the first dates in your selected range

    then click Format and choose you colour pattern. Click Ok and click Ok again to finish.

    Note: This will highlight actual dates that are in the months after the planned date, whether it is 1 month after or 2 or 3, etc...

    if you only want dates that are within only 1 month after then use formula:

    =MONTH(B1)=MONTH(A1)+1
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Registered User
    Join Date
    12-15-2006
    Posts
    25
    Thanks - just got back to this after the holidays.

    This works well for months within the same year, but doesn't work across years. For example, I've expanded the formatting so that later months highlight in red, and earlier months highlight in green. So, Dec 07 is earlier than Jan 08, but highlights in red because Dec is later than January. But what I want is for it to highlight in green, because it's earlier.

    In other words, is there a variant of the formula that will cope with the year?

    Thanks

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Would this work?

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    12-15-2006
    Posts
    25
    Hi - yes, that works - but the effect is now that matching dates also highlight.
    Sorry - should have been clearer - dates are in the format dd/mmm/yy and what I need is:
    * month A (actual) matches month B (planned) - no conditional formatting
    * month A (actual) later than month B (planned) - highlight in red
    * month A (actual) earlier than month B (planned)- highlight in green

    So is there a tweak to the formula that would ignore matching months?

    Thanks

  6. #6
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Select From A2, downwards and go to Format|Conditional Formatting



    Try this for Red:

    Please Login or Register  to view this content.
    and this for Green:

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    12-15-2006
    Posts
    25
    Thanks - that works fine for red - any actual dates that fall in the following month to the planned date, or later, highlight in red.

    But it doesn't quite work for green - here, dates in the preceding month don't highlight properly.
    For example: planned date - 15 May 08; actual date - 15 April 08 - no green highlight (but there should be). Highlight doesn't appear unless date is 1 April 08, or earlier.

    I've tried tweaking the formula numbers to solve this 'preceding month' problem, but no success - any ideas?

    Thanks

  8. #8
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    I think it's better if you post a sample file and show which dates should be highlighted in which colours....I am getting confused about which date is planned and which is actual.

  9. #9
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,700
    Quote Originally Posted by NBVC
    Please Login or Register  to view this content.
    This will only format dates 2 months (or more) back

    you could make it

    =DATE(YEAR(A2),MONTH(A2),DAY(A2))<DATE(YEAR(B2), MONTH(B2),1)

    although I prefer

    =AND(A2<=B2-DAY(B2),A2<>"")

  10. #10
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Thanks daddylonglegs...

  11. #11
    Registered User
    Join Date
    12-15-2006
    Posts
    25
    That's great - thanks!

+ 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