+ Reply to Thread
Results 1 to 2 of 2

Nested IF Function - if todays date, then return this cell, if false, nested if function

  1. #1
    Registered User
    Join Date
    07-28-2020
    Location
    Perth, Australia
    MS-Off Ver
    10
    Posts
    1

    Nested IF Function - if todays date, then return this cell, if false, nested if function

    Hi all,

    I am using an if function to check a range of cells with dates, compare them to todays date, and if it matches todays date, to return the value of the cell above.
    So far I have the following formula working:
    =MIN(IF(J2:AF2=TODAY(), J1:AF1))
    It matches the cell with 03/03/2021 to todays date therefore If Function returns TRUE, and returns the value of the cell above, being 3.

    Capture1.JPG

    However, I wanted to expand on this for other months, as if I pasted that formula in the table of dates for February it realises that none of those dates matches today, and returns a 0. So, for months in the past, I want it to return the largest number in the range, and for months in the future, I want it to return zero.

    And so I actually got this formula working: (Gives me 20 for February, and 0 for April.
    =MIN(IF(J2:AF2=TODAY(),J1:AF1,IF(J2:AF2>TODAY(),0,(MAX(J1:AF1)))))

    Capture2.JPG
    Capture3.JPG

    This formula returns correct values for months in the past and months in the future, BUT, it now doesn't return the correct value for the current month - it is giving me 0 instead of 3. So its like its saying that the first if function is no longer returning TRUE, and so goes IF FALSE, and does the next if function...

    Capture4.JPG

    What have I done wrong??

    Thanks for any help!!
    Attached Files Attached Files

  2. #2
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,452

    Re: Nested IF Function - if todays date, then return this cell, if false, nested if functi

    Stay in H5 (March):
    TODAY()-DAY(TODAY())+1 : the 1st day of current month.
    Compare with J6: If <J6: in the past, if = J6, current, else, future

    So, formula in H5:
    =IF(TODAY()-DAY(TODAY())+1<J6,0,IF(TODAY()-DAY(TODAY())+1=J6,DAY(TODAY()),DAY(EOMONTH(J6,0))))

    For Feb, the list range was 26 days only, my formula assums it was wrong, and give 28/29 days
    If it was actual 26 days as per the list, try:
    =IF(TODAY()-DAY(TODAY())+1<J2,0,IF(TODAY()-DAY(TODAY())+1=J2,DAY(TODAY()),DAY(MAX(J2:AF2))))

    Hope it helps.
    Attached Files Attached Files
    Quang PT

+ 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. [SOLVED] nested IF function to return number and >=(60>=)
    By Shawn99 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-03-2020, 03:00 AM
  2. Replies: 2
    Last Post: 01-05-2019, 03:33 AM
  3. [SOLVED] Nested If Function Ignore False Values and Continue Evaluation + Concatenation
    By cullenju in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-18-2018, 11:52 AM
  4. Nested If function returning FALSE instead of number
    By erimhast in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 12-09-2015, 07:47 PM
  5. [SOLVED] Mid Function nested in Index return #N/A
    By ibuhary in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-08-2015, 03:12 AM
  6. [SOLVED] Nasty nested IF function will only return "value if false"
    By Postlki1 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-20-2013, 05:19 AM
  7. Nested Lookup Function to Return a Value
    By ArenaNinja in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-25-2007, 12:44 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