+ Reply to Thread
Results 1 to 7 of 7

Calculating number of days from "today" and assigning a value of 0, 1, 2 or 3

  1. #1
    Forum Contributor
    Join Date
    05-01-2013
    Location
    Richmond, VA
    MS-Off Ver
    Excel 365
    Posts
    164

    Calculating number of days from "today" and assigning a value of 0, 1, 2 or 3

    I think I may have explained the request incorrectly and want to open this back up with a better worded problem statement:

    How do I create a the formula using the following conditions for todays date:

    0 would be for blank cells or cells that have the word "COMPLETE" or "N/A" in them
    1 would be for cells that are 7 prior to today's date
    2 would be for cells that are 8 to 14 days prior to today's date
    3 would be for cells that are 15 days prior to today's date
    4 would be for dates in the future from today's date

    For example if the date 01/03/2018 is in cell A2 and today's date is 01/11, 2018, the number of days is 8 and thus the value assigned via the formula will be 2.

    Thank you
    Last edited by Hedy; 01-11-2018 at 03:43 PM. Reason: Hopefully more clearly explained

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: Calculating number of days from "today" and assigning a value of 0, 1, 2 or 3

    Try

    =IF(OR(A2="COMPLETE",A2="N/A",LEN(A2)=0),0,LOOKUP(TODAY()-A2,{0,8,15},{1,2,3})
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Forum Contributor
    Join Date
    05-01-2013
    Location
    Richmond, VA
    MS-Off Ver
    Excel 365
    Posts
    164

    Re: Calculating number of days from "today" and assigning a value of 0, 1, 2 or 3

    I forgot to add an argument for "NEED," which I added to the formula below, and for dates in the future

    =IF(OR(L5="NEED",L5="COMPLETED",L5="N/A",LEN(L5)=0),0,LOOKUP(TODAY()-L5,{0,8,15},{1,2,3}))

    Using the formula above, how/where would I add for dates greater than today=0

  4. #4
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: Calculating number of days from "today" and assigning a value of 0, 1, 2 or 3

    See if this works (untested)

    =IF(OR(L5="NEED",L5="COMPLETED",L5="N/A",LEN(L5)=0),0,LOOKUP(L5-TODAY(),{-15,-8,0,1},{3,2,1,4}))

    You havent stated what return value you want for dates in the future, I picked 4.
    If you want other barriers in the future add them after the 1 in the first set of braces, and remember to add an accompanying return value in the second set of braces

  5. #5
    Forum Contributor
    Join Date
    05-01-2013
    Location
    Richmond, VA
    MS-Off Ver
    Excel 365
    Posts
    164

    Re: Calculating number of days from "today" and assigning a value of 0, 1, 2 or 3

    I am seeing #N/A for the 1, 2 and 3 values now. The 0 and 4 (thanks for adding that 4) are good.

  6. #6
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: Calculating number of days from "today" and assigning a value of 0, 1, 2 or 3

    make a blank sheet

    in A2 put =TODAY()
    in A1 put =A2+1
    in A3 put =A2-1
    in A4 put =A2-9
    in A5 put =A2-16

    These values each lie within the four areas that you've defined in your original post: future dates, 0-7 in the past 8-15 in the past, more than 15 days in the past.

    in B1
    =IF(OR(A1="NEED",A1="COMPLETED",A1="N/A",LEN(A1)=0),0,LOOKUP(A1-TODAY(),{-9.99999999999999E+307,-15,-8,0,1},{3,2,1,0,4}))
    and copy down

    You should get a column with 4, 0, 1, 2, 3

  7. #7
    Forum Contributor
    Join Date
    05-01-2013
    Location
    Richmond, VA
    MS-Off Ver
    Excel 365
    Posts
    164

    Re: Calculating number of days from "today" and assigning a value of 0, 1, 2 or 3

    This formula worked - THANK YOU!

+ 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. If Sheet("Entry").range("P3") has not today date then run macro
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-20-2016, 12:13 PM
  2. Getting month number from week based on number of "work days"
    By bergsorensen in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-11-2014, 07:21 AM
  3. Filter Dates to Reflect: "Today - 30 days or More"
    By Gard5096 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-11-2012, 11:42 AM
  4. "IF()" function using "TODAY()" to produce a value in days
    By Rob.Marchel in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-06-2012, 09:12 PM
  5. [SOLVED] How to Count number of "Error" and "OK" after the word "Instrument" found in table row
    By eltonlaw in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-17-2012, 06:26 AM
  6. Converting number of days to "months/days"
    By livemusic in forum Excel General
    Replies: 2
    Last Post: 04-11-2012, 06:36 PM
  7. Replies: 8
    Last Post: 02-23-2005, 06:58 PM

Tags for this Thread

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