+ Reply to Thread
Results 1 to 18 of 18

Counting number of items in column since last blank

  1. #1
    Registered User
    Join Date
    11-25-2015
    Location
    Minneapolis, MN
    MS-Off Ver
    2013
    Posts
    47

    Counting number of items in column since last blank

    Hi all,

    Is there a way to count the number of occurrences of text in a column, but only counting text since the last blank line?

    Example:

    Text
    Text
    Text
    Text
    [blank]
    Text
    Text
    Text
    Text
    Text
    Text
    Text
    Text


    I would want it to give me the number 8, which is the count of all the items since the last blank.
    Can you help? My boss has asked me for this and I'm still learning Excel, so any input would be greatly appreciated! Thank you!

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: Counting number of items in column since last blank

    Is there only ONE blank in the column? Or could there be more than one blank?
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: Counting number of items in column since last blank

    I'm sure there's a better way

    This assumes ONE blank ONLY in the column

    =COUNTA(INDIRECT("A"&MATCH(TRUE,INDEX((A1:A100=0),0),0)&":A100"))

  4. #4
    Registered User
    Join Date
    11-25-2015
    Location
    Minneapolis, MN
    MS-Off Ver
    2013
    Posts
    47

    Re: Counting number of items in column since last blank

    There will be multiple blanks. It's a column of 366 lines, each line corresponds to a date. In this particular column, we write the issue occurring on that date, and once the issue is resolved, it's no longer listed for the following days. My boss wants me to count the number of days that there has been an issue. So if the line is blank, that means no issue; once it has text in it, that means it's day 1 of the issue, etc. I hope this makes sense!

  5. #5
    Valued Forum Contributor Gatti's Avatar
    Join Date
    06-08-2015
    Location
    Brasil, São Paulo, Ribeirão Preto
    MS-Off Ver
    365
    Posts
    346

    Re: Counting number of items in column since last blank

    Lets use the following example:

    If I had this Column A (row / text):

    01 / A
    02 / A
    03 / A
    04 / A
    05 / A
    06 / A
    07 / A
    08 / A
    09 / A
    10 /
    11 / A
    12 / A
    13 / A
    14 /
    15 / A
    16 / A
    17 / A
    18 / A
    19 / A
    20 /
    21 / A
    22 / A
    23 / A
    24 /
    25 / A
    26 / A
    27 / A

    The empty spots are the blank cells

    Put this formula where you want to count:

    Please Login or Register  to view this content.
    Don't forget to CTRL + SHIFT + Enter after... cause it is a matrix

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

    Re: Counting number of items in column since last blank

    Another solution with Frequency:

    Please Login or Register  to view this content.
    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer. Press F2 on that cell and try again.
    Quang PT

  7. #7
    Registered User
    Join Date
    11-25-2015
    Location
    Minneapolis, MN
    MS-Off Ver
    2013
    Posts
    47

    Re: Counting number of items in column since last blank

    If this was taking place in column U rows 2-367, would I replace A1:A27 with U2:U367, etc for the whole thing?

  8. #8
    Registered User
    Join Date
    11-25-2015
    Location
    Minneapolis, MN
    MS-Off Ver
    2013
    Posts
    47

    Re: Counting number of items in column since last blank

    Another solution with Frequency:
    copy to clipboard
    =INDEX(FREQUENCY(IF($A$2:$A$11<>"",ROW($A$2:$A$11),""),IF($A$2:$A$11="",ROW($A$2:$A$11),"")),COUNTBLANK($A$2:$A$11)+1)
    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer. Press F2 on that cell and try again.
    I just tried this and it's giving me 0, even though I put text in the column as a test

  9. #9
    Valued Forum Contributor Gatti's Avatar
    Join Date
    06-08-2015
    Location
    Brasil, São Paulo, Ribeirão Preto
    MS-Off Ver
    365
    Posts
    346

    Re: Counting number of items in column since last blank

    You replace the OFFSET($A$1 for OFFSET($U$2) and the range $A$1:$A$27 for $U$2:$U$367

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

    Re: Counting number of items in column since last blank

    Another solution requiring ARRAY (Cntrl shft Enter)

    =MATCH("zzz",A:A)-MATCH(2,1/ INDEX(A1:INDEX(A:A,MATCH("zzz",A:A))="",))
    replace A with U. This formula figures out where your last text (i.e. U367)
    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

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

    Re: Counting number of items in column since last blank

    Quote Originally Posted by lbickford View Post
    I just tried this and it's giving me 0, even though I put text in the column as a test
    Have you confirmed by hitting Ctrl-shift-enter?

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

    Re: Counting number of items in column since last blank

    Try this array formula**:

    =LOOKUP(1E100,1/(1/FREQUENCY(IF(A2:A25<>"",ROW(A2:A25)),IF(A2:A25="",ROW(A2:A25)))))

    ** 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.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  13. #13
    Registered User
    Join Date
    11-25-2015
    Location
    Minneapolis, MN
    MS-Off Ver
    2013
    Posts
    47

    Re: Counting number of items in column since last blank

    Quote Originally Posted by bebo021999 View Post
    Have you confirmed by hitting Ctrl-shift-enter?
    Yes, and the brackets showed up and everything.

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

    Re: Counting number of items in column since last blank

    Working example of my formula (in cell A1)
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    11-25-2015
    Location
    Minneapolis, MN
    MS-Off Ver
    2013
    Posts
    47

    Re: Counting number of items in column since last blank

    This looks like it's exactly what I need! I am trying to upload the book I'm working in but it's not loading. Here's a twist - can we make it so that if Column A reads today's date, and the text of the column question is blank on the same row as today's date, the cell with our formula shows 0? or better yet, blank?

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

    Re: Counting number of items in column since last blank

    You lost me on that last question. If your workbook is too large it won't load, trim down your data.

  17. #17
    Registered User
    Join Date
    11-25-2015
    Location
    Minneapolis, MN
    MS-Off Ver
    2013
    Posts
    47

    Re: Counting number of items in column since last blank

    Quote Originally Posted by ChemistB View Post
    You lost me on that last question. If your workbook is too large it won't load, trim down your data.
    11.9 KB and it's still not loading Today is just not my day!

  18. #18
    Registered User
    Join Date
    11-25-2015
    Location
    Minneapolis, MN
    MS-Off Ver
    2013
    Posts
    47

    Re: Counting number of items in column since last blank

    Quote Originally Posted by ChemistB View Post
    You lost me on that last question. If your workbook is too large it won't load, trim down your data.

    Basically I need this whole formula to be conditional on the fact that today's date is found in column that lists all 366 days of the year. Say today's date is in row 10. If row 10 doesn't have text in it in the column that I'm trying to count (not the date column, the column where I'm trying to count occurrences of text), then the formula doesn't have to count the last occurrences of text and can read 0. I really wish I could upload the workbook to show you!

+ 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] To compare a list of items in column ? with items in all columns that are not blank.
    By JamesJohnson31 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-03-2015, 03:32 PM
  2. [SOLVED] Counting the number items based on number of days
    By Ltat42a in forum Excel General
    Replies: 6
    Last Post: 10-29-2014, 07:11 PM
  3. counting the number of closed items
    By ECYOJ in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-07-2014, 02:04 AM
  4. [SOLVED] Counting number of non-blank cells in column......but getting run time error in vba
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-30-2012, 10:54 AM
  5. counting number of unique items in column
    By maacmaac in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-10-2008, 02:17 PM
  6. Replies: 2
    Last Post: 11-01-2007, 09:32 PM
  7. Replies: 10
    Last Post: 03-20-2005, 02:06 PM

Tags for this Thread

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