+ Reply to Thread
Results 1 to 6 of 6

Format cell based on months that have elapsed

  1. #1
    Registered User
    Join Date
    09-09-2020
    Location
    Scotland
    MS-Off Ver
    Office 365
    Posts
    3

    Format cell based on months that have elapsed

    Hi there,

    Looking for some help with a formatting on excel.

    I have a cell which contains a date an item was received (D2 in this example).

    I would like another cell to change colour based on how many months have elapsed since that item was received (needs to be months).

    I need the cell to be green if less than 5 months have elapsed, yellow if between 5 to 6 months have elapsed and red if more than 6 months have elapsed.

    I have one rule with =DATEDIF($D2+1,TODAY(),"m")<5 to make less than 5 months be green.

    I have a second rule with =DATEDIF($D2+1,TODAY(),"m")>6 to make more than 6 months red.

    I am struggling to format between 5 and 6 months to be yellow?

    Any help would be appreciated.

    Thank you!

  2. #2
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.84 (24041420))
    Posts
    8,751

    Re: Format cell based on months that have elapsed

    can you attach a sample spreadsheet
    using your formula
    =OR(DATEDIF($D2+1,TODAY(),"m")=5,DATEDIF($D2+1,TODAY(),"m")=6)
    Otherwise
    If you order and STOP if true
    so >6 should be first in the list and then STOP if TRUE
    followed by
    DATEDIF($D2+1,TODAY(),"m")>4
    Stop if true
    Wayne
    if my assistance has helped, and only if you wish to , there is an "* Add Reputation" on the left hand side - you can add to my reputation here

    If you have a solution to your thread - Please mark your thread solved do the following: >
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,733

    Re: Format cell based on months that have elapsed

    Conditional Formatting follows a hierarchy, depending on the order that the conditions appear, so if neither of the two conditions that you have outlined are satisfied, then the elapsed time must be between 5 and 6 months (assuming it is not blank). If you just applied normal formatting of yellow to the cell, then it will show as such for 5 or 6 months. Just to be sure, you could apply a third CF condition which tests for $D2 not being blank, but make sure this condition is third on the list:

    =$D2<>""

    Alternatively, you could test specifically for your condition like this:

    =AND(DATEDIF($D2+1,TODAY(),"m")>=5, DATEDIF($D2+1,TODAY(),"m")<=6)

    Hope this helps.

    Pete

  4. #4
    Registered User
    Join Date
    09-09-2020
    Location
    Scotland
    MS-Off Ver
    Office 365
    Posts
    3

    Re: Format cell based on months that have elapsed

    Quote Originally Posted by etaf View Post
    can you attach a sample spreadsheet
    using your formula
    =OR(DATEDIF($D2+1,TODAY(),"m")=5,DATEDIF($D2+1,TODAY(),"m")=6)
    Otherwise
    If you order and STOP if true
    so >6 should be first in the list and then STOP if TRUE
    followed by
    DATEDIF($D2+1,TODAY(),"m")>4
    Stop if true
    That formula works, however I have one slight issue.

    Everything 5 months or less does turn green.

    Also everything over 5 months turns yellow but this somehow stays yellow until 7 months?

    Then anything over 7 months turns red instead?

    I cant attach my sheet or a sample unfortunately due to it being on a work machine, apologies.

  5. #5
    Registered User
    Join Date
    09-09-2020
    Location
    Scotland
    MS-Off Ver
    Office 365
    Posts
    3

    Re: Format cell based on months that have elapsed

    Managed to sort the problem

    I changed =AND(DATEDIF($D2+1,TODAY(),"m")>=5, DATEDIF($D2+1,TODAY(),"m")<=6) to =AND(DATEDIF($D2+1,TODAY(),"m")>=5, DATEDIF($D2+1,TODAY(),"m")<=5)

    also changed =DATEDIF($D2+1,TODAY(),"m")>6 to =DATEDIF($D2+1,TODAY(),"m")>5

    Seems to have solved the issue and now the colours change as needed.


    Many thanks for your help and to those who replied.

  6. #6
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.84 (24041420))
    Posts
    8,751

    Re: Format cell based on months that have elapsed

    you are welcome

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Change cell colours based on months days elapsed from another cell
    By ProfessorP29 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-11-2015, 02:44 PM
  2. [SOLVED] calculate numbers of days elapsed a week, month or 6 months from now
    By labogola in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 01-01-2014, 09:14 AM
  3. Number of months (elapsed months) between two dates
    By Timbite in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-17-2012, 11:37 AM
  4. Count Number Of Elapsed Months
    By simonyglog in forum Excel General
    Replies: 4
    Last Post: 04-08-2011, 10:34 AM
  5. Elapsed Years : Months: Days
    By Larry.LeBlanc@O in forum Excel General
    Replies: 1
    Last Post: 04-01-2010, 12:07 PM
  6. Excel formats for ELAPSED years months days
    By Larry.LeBlanc@O in forum Excel General
    Replies: 1
    Last Post: 03-31-2010, 07:56 PM
  7. Elapsed months
    By Redd in forum Excel General
    Replies: 3
    Last Post: 07-19-2009, 04:32 PM

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