+ Reply to Thread
Results 1 to 7 of 7

Help needed with IF formula

  1. #1
    Registered User
    Join Date
    10-07-2014
    Location
    Norwich, England
    MS-Off Ver
    365
    Posts
    58

    Help needed with IF formula

    Hi all

    I've been struggling with how to structure this formula for a while now and cannot quite figure it out and get it working correctly.

    I have a 'Start Date' field - M6
    I have a 'Initial Finish Date' field - O6
    I have 'Current Planned Finish' - P6 and
    I have 'Forecast Finish' - Q6

    Column R is the Duration of each Project. In Cell R6, I would like to return the number of months between the Start Date (M6) and the Forecast Finish (Q6), but...

    If Q6 is blank, return the number of months between the Start Date (M6) and the Current Planned Finish (P6) and..

    If P6 is blank, return the number of months between the Start Date (M6) and the Initial Finish Date (O6)...

    The formula I'm using to work out the duration between whichever dates is...
    =(YEAR(EndDate)-YEAR(StartDate))*12+MONTH(EndDate)-MONTH(StartDate)+1 (I've used the +1 because all the start dates tend to be the 1st of the month and all the end dates tend to be the end of the month, so without it 01/01/14 to 31/01/14 would pull back a value of zero).

    Really appreciate anyone's help.

    Thanks
    Tom

  2. #2
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Help needed with IF formula

    Try

    =DATEDIF(M6,LOOKUP(3000000,O6:Q6),"M")+1

  3. #3
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.95 for Mac MS 365
    Posts
    8,682

    Re: Help needed with IF formula

    here is what I came up with =IF(Q6<>"",DATEDIF(M6,Q6,"m"),IF(P6<>"",DATEDIF(M6,P6,"m"),DATEDIF(M6,O6,"m")))
    limited testing but it appears to work.
    Make contributors happy, click on the "* Add Reputation" as a way to say thank you.
    Sam Capricci

  4. #4
    Registered User
    Join Date
    10-07-2014
    Location
    Norwich, England
    MS-Off Ver
    365
    Posts
    58

    Re: Help needed with IF formula

    Haha wow! That is impressive! Thank you!

    How is it working? What does the 3000000 do?

    Cheers
    Tom

  5. #5
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: Help needed with IF formula

    Ive gone with a different approach, involving a hidden column (S) containing:

    =IF(ISNUMBER(Q6),Q6,IF(ISNUMBER(P6),P6,R6))

    then in R6 I have:
    = ((YEAR(S6) - YEAR(M6)) * 12) + MONTH(S6) - MONTH(M6)

  6. #6
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Help needed with IF formula

    You're welcome..

    This part
    LOOKUP(3000000,O6:Q6)
    Finds the cell furthest to the right with a Date in it.
    The 3000000 is just used as number garanteed larger than any date in the range O6:Q6

    The largest date allowed in excel is 12/31/9999
    In the numerical value for that date is 2958465 (I just rounded up to a nice even 3 million)

  7. #7
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: Help needed with IF formula

    Quote Originally Posted by Jonmo1 View Post
    You're welcome..

    This part
    LOOKUP(3000000,O6:Q6)
    Finds the cell furthest to the right with a Date in it.
    The 3000000 is just used as number garanteed larger than any date in the range O6:Q6

    The largest date allowed in excel is 12/31/9999
    In the numerical value for that date is 2958465 (I just rounded up to a nice even 3 million)
    Loving that idea, if I may say so its genius.

+ 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. Replies: 3
    Last Post: 06-09-2014, 03:29 PM
  2. Replies: 7
    Last Post: 02-03-2013, 06:25 PM
  3. Replies: 16
    Last Post: 10-19-2012, 08:48 PM
  4. [SOLVED] index formula needed--how to get a formula to skip columns
    By rsmidtisu in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 10-02-2012, 11:22 AM
  5. Replies: 3
    Last Post: 09-07-2012, 12:07 AM

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