+ Reply to Thread
Results 1 to 12 of 12

Trying to add 7 cells but get to reset when a cell is zero

  1. #1
    Registered User
    Join Date
    03-11-2016
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    10

    Trying to add 7 cells but get to reset when a cell is zero

    Hi there,

    I am trying to add 7 columns. But if one of those columns is zero, I need it to reset and start over.

    Can anyone help me with this? I am calculating hours for for our drivers and the rule is that they cannot drive more than 70 hours in 7 days. If they take a day off, then they can start over. So if I enter zero, I need the total to reset and start over. Does this make sense?

    Thank you so much for any help.

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Trying to add 7 cells but get to reset when a cell is zero

    So you want to sum columns 1 to 7 but from the last zero
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Trying to add 7 cells but get to reset when a cell is zero

    Which columns (starting at ? ending at?)
    Do the "zero" columns actually contain 0 or are they blank or contain something else (dash, N/A, etc)

    So you basically want to sum within a row, from the last number on the right back to either the last 0 or 7 cells whichever is less
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  4. #4
    Registered User
    Join Date
    03-11-2016
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    10

    Re: Trying to add 7 cells but get to reset when a cell is zero

    Yes exactly

  5. #5
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Trying to add 7 cells but get to reset when a cell is zero

    Try this, let's say we're working in row 2

    =MIN(SUM(INDEX(2:2,LOOKUP(2,1/((2:2=0)*ISNUMBER(2:2)), COLUMN(2:2))):INDEX(2:2, MATCH(99,2:2))), SUM(INDEX(2:2, MATCH(99,2:2)-6):INDEX(2:2, MATCH(99,2:2)))

    It sums the numbers from the last 0 to the end and the numbers of the last 7 and takes whichever is less.

  6. #6
    Registered User
    Join Date
    03-11-2016
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    10

    Re: Trying to add 7 cells but get to reset when a cell is zero

    Thank you so much. It does work, however I need it to start adding again from the last zero. Is this possible?

  7. #7
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Trying to add 7 cells but get to reset when a cell is zero

    Unless something is going wrong, it will always add from the last 0 (or last 7 days if there is no 0 in last 7 days)
    If you have a specific issue, try uploading a spreadsheet, (Go Advanced>Manage Attachments)

  8. #8
    Registered User
    Join Date
    03-11-2016
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    10

    Re: Trying to add 7 cells but get to reset when a cell is zero

    Here is the spreadsheet....Thanks
    Attached Files Attached Files

  9. #9
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Trying to add 7 cells but get to reset when a cell is zero

    Okay, just so we can use 1 formula all the way through, In A3 (I put it in A4) copied to the right

    =MIN(SUM(INDEX(A2:$A2,COLUMNS($A2:A2)-MIN(COLUMNS($A2:A2)-1,6)):A2), IFERROR(SUM(INDEX($A2:A2,LOOKUP(2,1/(($A2:A2=0)*ISNUMBER($A2:A2)), COLUMN($A2:A2))):A2),900))

    Questions or problems?
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    03-11-2016
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    10

    Re: Trying to add 7 cells but get to reset when a cell is zero

    Thank you so so so much! You ROCK!

  11. #11
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Trying to add 7 cells but get to reset when a cell is zero

    Glad to help.

  12. #12
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Trying to add 7 cells but get to reset when a cell is zero

    Thanks Chemist, for the life of me I couldn't get a formula to work in a single cell

+ 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. [SOLVED] I need a macro that will reset cells to zero
    By Macro Beginner in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-19-2019, 01:31 AM
  2. [SOLVED] Every Certain Sum I want to Reset My Cells - Need Equation
    By neelpatel in forum Excel General
    Replies: 9
    Last Post: 07-30-2012, 01:02 AM
  3. Reset cells Macro
    By barcas84 in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 01-19-2012, 03:15 PM
  4. Cells Row Position Always reset to 1
    By Fankie1228 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-04-2011, 03:56 AM
  5. Two cell accumulator then reset first cells
    By stanster in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 01-20-2008, 12:15 PM
  6. Reset cells to zero
    By no dice in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-19-2007, 10:20 PM
  7. [SOLVED] reset cells to 0 all at once
    By Workshops in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 02-19-2006, 08:45 PM
  8. reset cells
    By 1vagrowr in forum Excel General
    Replies: 8
    Last Post: 12-21-2005, 01:20 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