+ Reply to Thread
Results 1 to 16 of 16

Re-Calc from new cell if so many cells are blank

  1. #1
    Registered User
    Join Date
    11-11-2008
    Location
    Canada
    Posts
    15

    Re-Calc from new cell if so many cells are blank

    I have 2 columns.

    Column E has the amount of time each day.
    Column G is where I want the Sum to be displayed.

    I need Column G to do a =Sum(E4:E33), but if anywhere in between E4 and E33 there is a period of 5 days where it totals 0 then I want column G to re-add from the first day where there is a amount in it.

    Ex: E4 to E10 totals 7 (1 per day), from E11 to E15 totals 0, from E16 to E33 totals 18 (1 per day again).

    In Column G at G10 it should total 7, at G11 it should be 6, G12 5 etc until it hits G15 where it sees the 5 previous days nothing was entered so it enters a value of 0, because G15 is set to 0, G16 will start adding from E16 till E33, until somewhere down the line it sees another period of 5 days where it adds up to 0 again.
    Last edited by zny_kan; 11-11-2008 at 07:03 PM.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    What happens if there are more or less than 5 consecutive 0's?
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Registered User
    Join Date
    11-11-2008
    Location
    Canada
    Posts
    15
    If there are more than 5 days of 0 then whenever the first day where there is a value greater than 0 that's where it would start from 0 and start adding up from that day.

    What I want is to keep a running total in a given period say 30 days, but if a 5 or more days of 0 show up, i was column G to start adding up from the most recent day I put in a value.

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    What about if there are less than 5 0's?

    This is what I've got so far and it accounts for any number of 0's, not necessarily 5.

    In G4,

    =IF(ISNUMBER(MATCH(0,$E4:$E$33,0)-1),MATCH(0,$E4:$E$33,0)-1,COUNTIF(E4:$E$33,1)) copied down

    Does it work for you?

  5. #5
    Registered User
    Join Date
    11-11-2008
    Location
    Canada
    Posts
    15
    I'll try it out. thanks

  6. #6
    Registered User
    Join Date
    11-11-2008
    Location
    Canada
    Posts
    15
    Doesn't work out for me. Match will always return a value for me in the with the first 0 it sees. If I could get it to return the last 0 in a set of 5 or more then I could use that number plus a preset number, stick a letter in front of it to get the Cell number, and then use a sum formula
    Please Login or Register  to view this content.

  7. #7
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    If you post a sample sheet showing a sample listing and expected results, then it may be easire to get a working solution.

    Please ensure that the sample shows what will happen in different cases (ie. varying number of continuous 0's).

  8. #8
    Registered User
    Join Date
    11-11-2008
    Location
    Canada
    Posts
    15
    Here is it. I hide some columns because it's all just a repeat of this same column but with a different time limitation. And this would provide less clutter.
    Attached Images Attached Images

  9. #9
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Can you try again and upload an .XLS spreadsheet instead of a .jpg

  10. #10
    Registered User
    Join Date
    11-11-2008
    Location
    Canada
    Posts
    15
    on sheet 2010 is the jpg I posted, which I did some quick editting to simplify it.

    On sheet 2009, cell H33 is where I want to put the new formula we're trying to figure out in. The reason I want it in H33 is because it's the first cell in that column which has a simple formula vs. the cells above.

    So working from Sheet 2009 it keeps a running total of my 30 days flight time, from sheet 2009 and sheet 2008.

    If it sees 5 or more 0s in a row in the Flight Time column (E), the H column (I accidently put G when I first began this post) as soon as it see 5 or more 0 should reset to 0 and only start counting from whichever row the Flight Time (E) has a value greater than 0.
    Attached Files Attached Files

  11. #11
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    In H33:

    If you are entering 0's in column E, then....

    Please Login or Register  to view this content.

    If you are entering blanks for 0's in column H, then....

    Please Login or Register  to view this content.
    Either formula must be confirmed with CTRL+SHIFT+ENTER, not just ENTER and then copied down.
    Last edited by NBVC; 11-11-2008 at 06:35 PM.

  12. #12
    Registered User
    Join Date
    11-11-2008
    Location
    Canada
    Posts
    15
    Wow, seems to work perfect.

    Why did you put in $E$3 instead of $E$4, does it make a difference?

  13. #13
    Registered User
    Join Date
    11-11-2008
    Location
    Canada
    Posts
    15
    And thanks for helping me. I gotta lookup and find out what all those things in the formula does now.

  14. #14
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Quote Originally Posted by zny_kan View Post
    Wow, seems to work perfect.

    Why did you put in $E$3 instead of $E$4, does it make a difference?
    It doesn't make a difference. I just picked the wrong start of the range...

  15. #15
    Registered User
    Join Date
    11-11-2008
    Location
    Canada
    Posts
    15
    cool.

    While I was looking into the formula, I was wondering why under the Match function you divide 1 by the array
    Please Login or Register  to view this content.

  16. #16
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    That Match() formulation will find the last entry that matches the condition in the denominator of the Lookup Array argument (ie. the 2nd argument of the Match function).

    If you select the cell with the formula and go to Tools|Formula Auditing|Evaluate Formula and click Evaluate to step through the way the formula is evaluated, you will see what is going on.

    The denominator, when evaluated, creates an array of TRUEs and FALSEs depending on if the condition is met or not in each element of the array. The 1/denominator will then create an array of 1's or #DIV/0 errros because 1/TRUE is the same as 1/1 which =1 and 1/FALSE is the same as 1/0 which results in an error....

    Now the next thing for the Match() function to do is look for a 2 in that resultant array... It can't find one, but since the last (optional) argument of the Match function is left out, the function looks for the last entry in the array that is smaller than or equal to the 2.. ie. the last 1 in the array is targeted and that postion is returned... then the Index() part takes over and extracts the corresponding value.

    Hope that helps.

+ 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