+ Reply to Thread
Results 1 to 13 of 13

Running sum reset by zero

  1. #1
    Registered User
    Join Date
    01-06-2016
    Location
    Kansas
    MS-Off Ver
    2013
    Posts
    9

    Running sum reset by zero

    I need to keep a running sum for the last 7 days. If zero is entered (or blank) for a day, then the range should start over on that day... not count the last 7 days. In other words, a day with zero becomes day 1. Is this possible?

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Running sum reset by zero

    Hi, welcome to the forum

    I take it these are days of the week - are they dates or day numbers perhaps?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    01-06-2016
    Location
    Kansas
    MS-Off Ver
    2013
    Posts
    9

    Re: Running sum reset by zero

    thanks! must admit my brain is a bit fried from trying to figure this out! it's actually number of hours per day, for 7 days. running total cannot be greater than 60 (I have that part figured out). Then, if 34 hours off duty, hourly count starts over at zero... help! my struggle is how to tell Excel to only sum 1 day, then 2, etc up to 7 after a restart.

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Running sum reset by zero

    Do you have a sample workbook to share?

  5. #5
    Registered User
    Join Date
    01-06-2016
    Location
    Kansas
    MS-Off Ver
    2013
    Posts
    9

    Re: Running sum reset by zero

    Here is a sample. My formats are inconsistent, but I think this will help illustrate my question. sample.xlsx

  6. #6
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    18,905

    Re: Running sum reset by zero

    Try this array formula (activated by Ctrl+Shift+Enter) in C8 and down:
    Please Login or Register  to view this content.
    To hide the zero values, as was done for C2:C7 you could apply the conditional formatting rule Cell Value = 0 fill and font gray. Here is a copy of your file with the formula and formatting rule applied:
    Copy of sample-6.xlsx
    Let me know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

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

    Re: Running sum reset by zero

    Try in C8 then drag down:

    Please Login or Register  to view this content.
    Quang PT

  8. #8
    Registered User
    Join Date
    01-06-2016
    Location
    Kansas
    MS-Off Ver
    2013
    Posts
    9

    Re: Running sum reset by zero

    bebo021999 thank you! this works... I wish I could say I understand the formula, but this appears to be exactly what I need.

  9. #9
    Registered User
    Join Date
    01-06-2016
    Location
    Kansas
    MS-Off Ver
    2013
    Posts
    9

    Re: Running sum reset by zero

    Need help again... can this formula be applied with an 8 day rule (instead of 7)? I thought I would be able to modify the formula you provided, but I'm not sure how to do it...

  10. #10
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    18,905

    Re: Running sum reset by zero

    I can modify BeBo's formula to sum the previous eight days, however I didn't attempt to comply with the max 60 rule. The formula would need to be inserted at C9, as opposed to C8, and down. Here is the modified formula:
    Please Login or Register  to view this content.
    Let me know if you have any questions.

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

    Re: Running sum reset by zero

    @JeteMc: Thx for your update
    @sunflowersherri: Does it work for new request of 8 day rule?

  12. #12
    Registered User
    Join Date
    01-06-2016
    Location
    Kansas
    MS-Off Ver
    2013
    Posts
    9

    Re: Running sum reset by zero

    Yes! Thank you both! If you could be so kind, may you offer explanation as to how the formula works?

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

    Re: Running sum reset by zero

    OK.
    =IF(A9>=1.4167,0,IF(A8>=1.4167,SUM(B8:B9) (First 2 special cases)
    ,MIN of 2 cases
    (1)define last cell value >=1.4167(SUMPRODUCT(INDEX(B9:INDEX(B2:B8,IFERROR(LOOKUP(2,1/(A2:A8>1.4167),{1,2,3,4,5,6,7}),1)),))
    (2)entire range,SUM(B2:B9))))

    How (1) define last cell value>=1.4167?
    Assume A3=2.5 (>1.4167)
    (A2:A8>1.4167) = {FALSE,TRUE,FALSE,FALSE,FALSE,FALSE,FALSE}
    1/(A2:A8>1.4167) = {#DIV/0,1,#DIV/0,#DIV/0,#DIV/0,#DIV/0,#DIV/0}
    LOOKUP(2,1/(A2:A8>1.4167),{1,2,3,4,5,6,7})=2
    INDEX(B2:B8,IFERROR(LOOKUP(2,1/(A2:A8>1.4167),{1,2,3,4,5,6,7}),1)),)points to cell B3 (If the is no value>=1.4167,points to B2)
    INDEX(B9:INDEX(B2:B8,IFERROR(LOOKUP...)),)refer to range B3:B9
    Now (1)equals SUM(B3:B9)
    MIN(SUM(B3:B9),SUM(B2:B9)would take which is smaller

    Hope it helps

+ 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. Create running stopwatch/timer with 1 button (start/stop). No reset button.
    By leeroy2612 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-26-2021, 12:59 AM
  2. [SOLVED] Help! I need to create a running total that can will reset itself.
    By hackshow51 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 03-20-2015, 10:51 PM
  3. Need a formula for running total to reset at zero
    By jconnelley in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 05-05-2014, 03:18 PM
  4. Need Excel 2010 pivot table with running totals that reset to baseline
    By NYYfan in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 09-27-2013, 03:54 PM
  5. Macro to hide/unhide cells not running or running slow
    By mbp727 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-17-2013, 04:22 PM
  6. Replies: 1
    Last Post: 05-09-2012, 04:32 PM
  7. Running total reset by zero
    By flyp in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 02-21-2011, 06:49 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