+ Reply to Thread
Results 1 to 11 of 11

Count number of empty cells since last non-empty cell

Hybrid View

  1. #1
    Registered User
    Join Date
    03-17-2014
    Location
    S
    MS-Off Ver
    Excel 2010
    Posts
    19

    Count number of empty cells since last non-empty cell

    Here's the setup I'm working with.

    Excel.PNG

    It's a work out plan. Rows are dates, columns are exercises. Every time I complete the exercise "back" I insert a cross at the respective date.

    I need a way to count the rows since the last time I did a particular exercise. In the example, if it were currently 9/16 the solution should yield 9 days for the exercise "back", 1 day for the exercise "front" and 8 days for the exercise "oh". I should be able to apply the solution on the whole column "back". There might be several check marks in one column, I am only interested in the number of empty rows since the last check mark.

    Any help? Thanks.
    Attached Files Attached Files
    Last edited by rluesc; 09-26-2015 at 03:30 PM.

  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: Count number of empty cells since last non-empty cell

    1st, Please upload a sample of your workbook, not a picture of your data. Pictures are pretty much impossible to edit, and no-one wants to re-type your data for you
    Also, not all members can upload picture files (Company firewalls and stuff) - and, depending on what browser is being used, some pics dont even show up on the forum

    Your workbook should show a small desensitized example of the data you are working with and a manual mockup of the expected results.

    2nd, do you have to use letters, could you use a number (like 1?)
    3rd, do you only enter the date on that day, or are they copied down past "today"? (cant see the pic)
    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
    03-17-2014
    Location
    S
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Count number of empty cells since last non-empty cell

    I've added an exemplary work sheet to my first post.

    Quote Originally Posted by FDibbins View Post
    2nd, do you have to use letters, could you use a number (like 1?)
    Numbers would work fine too.

    Quote Originally Posted by FDibbins View Post
    3rd, do you only enter the date on that day, or are they copied down past "today"? (cant see the pic)
    Not sure if I understand you correctly, hope the Excel file clarifies my question. The whole spreadsheet is changing dynamically in so far as today I'm interested in the empty rows until today's date, tomorrow I'll be interested in the empty rows until tomorrow's date etc.

  4. #4
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Count number of empty cells since last non-empty cell

    Please upload a sample workbook, embedded PNG images are not visible to most users.

  5. #5
    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: Count number of empty cells since last non-empty cell

    Thanks for the file, it makes things much easier

    I added a row between the main heading and the exersizes, so the date can show there, and I changed teh "x" to 1 so that I could use this, copied across...
    =IFERROR(INDEX($A$4:$A$30,MATCH(0*1,B4:B30,-1)),"")

    regarding my comment "3rd, do you only enter the date on that day,..." I meant that do you enter the date each day, or put the dates in for the whole month (at the start of the month), but if you use numbers instead of letter, it doesnt matter
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    03-17-2014
    Location
    S
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Count number of empty cells since last non-empty cell

    Very neat, thank you so much. I'll toy around with the solution a bit and come back with any further questions.

  7. #7
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Count number of empty cells since last non-empty cell

    Try this in B28, then drag to copy to the other columns.
    Formula: copy to clipboard
    =TODAY()-LOOKUP("y",C$3:C$27,$A$3:$A$27)

  8. #8
    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: Count number of empty cells since last non-empty cell

    Jason, nice 1 - but you dont need the TODAY() part, just =LOOKUP("y",B$4:B$30,$A$4:$A$30)
    (I extended it to take 2 extra days for a 31-day month)

    Also, dontr know why I had 0*1 in my formula...
    =IFERROR(INDEX($A$4:$A$30,MATCH(0*1,B4:B30,-1)),"")
    It just needs to be...
    =IFERROR(INDEX($A$4:$A$30,MATCH(0,B4:B30,-1)),"")

    @ rluesc, if you want to stay with letters, use Jason's suggestion

  9. #9
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Count number of empty cells since last non-empty cell

    Ford, am I missing something in my suggestion or the requirement?

    I used TODAY()-LOOKUP to return the count of days since the last x in the column rather than the actual date, which, in theory would be the number of blanks since the last x.

    That said, theory always works well until you apply it to reality.

  10. #10
    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: Count number of empty cells since last non-empty cell

    Nope you are not missing anything, I am - I did not include the "days since last done" part

    Quote Originally Posted by jason.b75 View Post
    That said, theory always works well until you apply it to reality.
    Like the old addage goes - if the facts dont conform to the theroy...change the facts

    =IFERROR(TODAY()-INDEX($A$4:$A$30,MATCH(0,H4:H30,-1)),"")
    Last edited by FDibbins; 09-26-2015 at 08:36 PM.

  11. #11
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Count number of empty cells since last non-empty cell

    I used this method to calculate days since last time exercise was done. This is an array formula entered in a row inserted at row 2. Enter in B2 and fill across.
    Formula: copy to clipboard
    =TODAY()-INDEX($A4:$A1200,MAX(IF(B4:B1200="x",ROW(B4:B1200)))-3)

    Enter with Ctrl + Shift + Enter

    This will allow the table to be extended down to row 1200 to give you a little over 3 years of dates to be entered without doing anything other than filling in the data.
    Attached Files Attached Files
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

+ 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] excel 2010 empty a cell according to other cells (without Deleting them just show empty)
    By pavlos_x in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-11-2015, 01:46 PM
  2. Replies: 1
    Last Post: 05-26-2014, 01:31 PM
  3. Replies: 5
    Last Post: 05-13-2014, 10:19 AM
  4. Need to find empty filled cells in a column and copy to the empty cell below
    By Grahamfeeley in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-30-2014, 10:09 AM
  5. Replies: 2
    Last Post: 07-25-2013, 01:01 PM
  6. Count the number of cells in a range that are not empty
    By efernandes67 in forum Excel General
    Replies: 5
    Last Post: 07-23-2010, 05:41 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