+ Reply to Thread
Results 1 to 8 of 8

IF formula with too many nestings

  1. #1
    Forum Contributor
    Join Date
    10-30-2006
    MS-Off Ver
    O365
    Posts
    311

    IF formula with too many nestings

    Good afternoon,
    Can anyone help me - I'm trying to work out how to calculate the difference between today's value (currently in cell B8) and yesterday's value (currently in cell B7). The days of the month are set down column B.

    I started to use this formula where G2 is =now() Column A has the dates of the month and Column B has the value:
    =IF(G2=A8,B8-B7,IF(G2=A9,B9-B8,IF(G2=A10,B10-B9,IF(G2=A11,B11-B10,IF(G2=A12,B12-B11,IF(G2=A13,B13-B12,IF(G2=A14,B14-B13,IF(G2=A15,B15-B14,""))))))))

    I need to add more 'nestings' to be able to continue this for the entire month but it won't let me. Is there an easier way I can do this?

    Help is greatly appreciated.

  2. #2
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: IF formula with too many nestings

    I will suggest additional cell G3 contains:
    =MATCH(G2,A8:A38,0)
    to find position of today's date. Then result formula is:
    =INDEX(B8:B38,G3)-INDEX(B8:B38,G3-1)
    • Please remember to mark threads Solved with Thread Tools link at top of page.
    • Please use code tags when posting code: [code]Place your code here[/code]
    • Please read Forum Rules

  3. #3
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: IF formula with too many nestings

    =SUMPRODUCT((A8:15=G2)*(B8:15-B7:B14))

    expand the ranges as needed
    Make Mom proud: Add to my reputation if I helped out!

    Make the Moderators happy: Mark the Thread as Solved if your question was answered!

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

    Re: IF formula with too many nestings

    Assuming date list from A2 down.
    =SUMPRODUCT(($A$3:$A$41=G2)*($B$3:$B$41-$B$2:$B$40))
    Quang PT

  5. #5
    Forum Contributor
    Join Date
    10-30-2006
    MS-Off Ver
    O365
    Posts
    311

    Re: IF formula with too many nestings

    Thanks for all the replies.
    =SUMPRODUCT(($A$3:$A$41=G2)*($B$3:$B$41-$B$2:$B$40)) does work if i manually type the date into cell G2 but it doesn't if i use the =now() command, it give me an answer of 0.

    Is there anything I can do about this?

  6. #6
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: IF formula with too many nestings

    The NOW() function takes into account the time too. Use the TODAY() function instead
    Life's a spreadsheet, Excel!
    Say thanks, Click *

  7. #7
    Forum Contributor
    Join Date
    10-30-2006
    MS-Off Ver
    O365
    Posts
    311

    Re: IF formula with too many nestings

    Perfect! Thanks everyone, as always

  8. #8
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: IF formula with too many nestings

    Thanks for the feedback. Glad we were able to help.

+ 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. how to hide formula in formula box, view lookup result in formula box?
    By vengatvj in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-14-2013, 04:06 PM
  2. Reducing number of nestings in formula
    By Hayley911 in forum Excel General
    Replies: 3
    Last Post: 02-16-2012, 03:09 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