+ Reply to Thread
Results 1 to 11 of 11

Return date at which a sum was reached

  1. #1
    Registered User
    Join Date
    10-18-2013
    Location
    United States
    MS-Off Ver
    Excel 2007, 2013
    Posts
    10

    Return date at which a sum was reached

    Hello all,

    I have a spread sheet that in column A, lists dates consecutively. In Column B, I have a value for each date.

    Now, I want to be able to enter a start date somewhere else, say F3. Then I want F4 to start adding the value in column B beginning at the date I entered in F3. When the sum reaches a certain number, I want it to stop and tell me on what date the sum was reached. Check out the attachment for a much clearer example.

    Thanks!
    mihigh07
    Attached Files Attached Files

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

    Re: Return date at which a sum was reached

    use a helper column (Col. C). In C2
    =IF(A2<$F$3,"",SUM(C1,B2))

    copy down

    then use
    =INDEX(A:A,MATCH(F2,C:C)+1)
    Life's a spreadsheet, Excel!
    Say thanks, Click *

  3. #3
    Registered User
    Join Date
    10-18-2013
    Location
    United States
    MS-Off Ver
    Excel 2007, 2013
    Posts
    10

    Re: Return date at which a sum was reached

    That is exactly what I needed...Thanks!

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Return date at which a sum was reached

    Based on your last post in this thread, its apparent that you are satisfied with the solution(s) you've received and have solved your question, but you haven't marked your thread as "SOLVED". I will do it for you this time.

    In future, to mark your thread as Solved, you can do the following -
    Select Thread Tools-> Mark thread as Solved.

    Incase your issue is not solved, you can undo it as follows -
    Select Thread Tools-> Mark thread as Unsolved.

    Also, since you are relatively new to the forum, i would like to inform you that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post which helped you. This adds to the reputation of the person who has taken the time to help you.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  5. #5
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Return date at which a sum was reached

    If you want a single formula...

    This array formula** entered in F4:

    =INDEX(A551:INDEX(A2:A551,MATCH(F3,A2:A551,0)),MATCH(TRUE,SUBTOTAL(9,OFFSET(B2,MATCH(F3,A2:A551,0)-1,,ROW(INDIRECT("1:"&COUNT(A551:INDEX(A2:A551,MATCH(F3,A2:A551,0)))))))>=F2,0))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

    Format as Date
    Last edited by Tony Valko; 10-19-2013 at 10:40 AM.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  6. #6
    Registered User
    Join Date
    10-18-2013
    Location
    United States
    MS-Off Ver
    Excel 2007, 2013
    Posts
    10

    Re: Return date at which a sum was reached

    Mad props Tony, this too is awesome.

    Any way to make it detect the length of the array, rather than having to tell it "A551"?

  7. #7
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Return date at which a sum was reached

    It makes things a bit more complex but it can be done.

    Create this defined named formula:

    Goto the Formulas tab>Define Name
    Name: Dates
    Refers to: =$A$2:INDEX($A:$A,MATCH(1E+100,$A:$A))
    OK

    Then, this array formula** entered in F4:

    =INDEX(INDEX(Dates,MATCH(1E+100,Dates)):INDEX(Dates,MATCH(F3,Dates,0)),MATCH(TRUE,SUBTOTAL(9,OFFSET(B2,MATCH(F3,Dates,0)-1,,ROW(INDIRECT("1:"&COUNT(INDEX(Dates,MATCH(1E+100,Dates)):INDEX(Dates,MATCH(F3,Dates,0)))))))>=F2,0))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

  8. #8
    Registered User
    Join Date
    10-18-2013
    Location
    United States
    MS-Off Ver
    Excel 2007, 2013
    Posts
    10

    Re: Return date at which a sum was reached

    Tony,

    You helped me create this awesome formula months ago, now it has evolved a bit into what is in the attached spreadsheet. I am now having trouble with it returning the wrong date in only some cells. Can you help me troubleshoot? See sheet "Actual peaks" to view the problem.

    Thanks!
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    10-18-2013
    Location
    United States
    MS-Off Ver
    Excel 2007, 2013
    Posts
    10

    Re: Return date at which a sum was reached

    Tony,

    You helped me create this awesome formula months ago, now it has evolved a bit into what is in the attached spreadsheet. I am now having trouble with it returning the wrong date in only some cells. Can you help me troubleshoot? See sheet "Actual peaks" to view the problem.

    Thanks!
    Attached Files Attached Files

  10. #10
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Return date at which a sum was reached

    Please refresh my memory.

    Just looking at your file I can't follow what you're wanting to do. The manual result that I get is not even close to the formula result.

  11. #11
    Registered User
    Join Date
    08-19-2020
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    1

    Re: Return date at which a sum was reached

    Hi, I want to thank the OP mihigh for this post as well as Ace_XL for providing a great solution. I am quite new to Excel formulas and so there is still a few things within the formula that I don't understand, but I'm usually a quick learner.

    I am using this exact solution in my spreadsheet with my own cell references as for the most part it is does exactly what I need and what I expect.

    If the sum has not yet been reached within the data, it returns the date '0 January 1900'. Is there a way I can either, get it to display nothing if the sum is not reached, or perhaps some custom text?

    Total noob here Apologies if this is a basic things and I just don't have the information yet.
    Last edited by Yorozuya; 08-20-2020 at 05:16 PM.

+ 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: 2
    Last Post: 08-01-2013, 04:49 AM
  2. Replies: 4
    Last Post: 09-05-2012, 05:25 AM
  3. Replies: 1
    Last Post: 04-18-2012, 05:49 PM
  4. Replies: 2
    Last Post: 09-09-2011, 12:30 PM
  5. Formula to return date that a Percentage is reached.
    By lucraft in forum Excel General
    Replies: 0
    Last Post: 07-19-2011, 09:47 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