+ Reply to Thread
Results 1 to 9 of 9

Formula using sumif depending on date in two cells

  1. #1
    Forum Contributor
    Join Date
    12-03-2009
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    184

    Formula using sumif depending on date in two cells

    Hello,

    I hope I can explain this well enough. I need a formula that checks for the oldest date in two different cells then calculates the sum.

    So, this is what I want to put in cell E2

    If date in A2 > date in C2 then B2 - D2 and If date in C2 > date in A2 then D2 - B2

    Except I want it in a real formula

    Thx
    E.

  2. #2
    Forum Expert Moo the Dog's Avatar
    Join Date
    09-28-2012
    Location
    Wisconsin
    MS-Off Ver
    Office 365 (PC & Mac)
    Posts
    1,845

    Re: Formula using sumif depending on date in two cells

    Would this be a simple IF -THEN kind of problem? Like this:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    - Moo

  3. #3
    Forum Contributor
    Join Date
    12-03-2009
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    184

    Re: Formula using sumif depending on date in two cells

    Thanks, but it doesn't account for date in C2 being greater then the date in A2.

  4. #4
    Forum Expert Moo the Dog's Avatar
    Join Date
    09-28-2012
    Location
    Wisconsin
    MS-Off Ver
    Office 365 (PC & Mac)
    Posts
    1,845

    Re: Formula using sumif depending on date in two cells

    Yes, it does.. that is what the IF statement does - exactly.

    =IF( LOGICAL CONDITION , DO 'THIS' IF TRUE , DO 'SOMETHING ELSE' IF FALSE )

    In every day terms my formula says:

    IF A2 is greater than C2, THEN subtract D2 from B2, OTHERWISE (if A2 is NOT greater than C2) subtract B2 from D2.

    The only problem you would run into would be if A2 = C2.

    - Moo

  5. #5
    Forum Contributor
    Join Date
    12-03-2009
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    184

    Re: Formula using sumif depending on date in two cells

    Thanks Moo, it works, but I'm running into the problem of the A2 = C2. I need to look at this some more and get back to the forum.

  6. #6
    Forum Expert Moo the Dog's Avatar
    Join Date
    09-28-2012
    Location
    Wisconsin
    MS-Off Ver
    Office 365 (PC & Mac)
    Posts
    1,845

    Re: Formula using sumif depending on date in two cells

    Well, what would you like the result to be when A2 = C2? That is an easy fix for this formula. The way the formula is set up right now " =if(A2>C2,B2-D2,D2-B2) " the condition A2 = C2 will return FALSE since A2 is NOT greater than C2, thus it will do the second result (D2-B2).

    When they are equal, do you want it to return an error, or a different value or formula? Let me know.

    - Moo

  7. #7
    Registered User
    Join Date
    11-14-2012
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2007
    Posts
    33

    Re: Formula using sumif depending on date in two cells

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  8. #8
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,448

    Re: Formula using sumif depending on date in two cells

    Eventually
    Please Login or Register  to view this content.
    (will return 0 if both are equal)

    @Vinoth : using IF twice works but is redundant Moo's answer covers that

  9. #9
    Forum Contributor
    Join Date
    09-11-2012
    Location
    Singapore
    MS-Off Ver
    Excel 2003, Excel 2007, Excel 2013
    Posts
    103

    Re: Formula using sumif depending on date in two cells

    Quote Originally Posted by Pepe Le Mokko View Post
    Please Login or Register  to view this content.
    @ Pepe Le Mokko

    Nice formula. It is a beautiful way of thinking.
    Click * to reward me...
    Thank you...

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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