+ Reply to Thread
Results 1 to 14 of 14

Count sets of text

Hybrid View

  1. #1
    Registered User
    Join Date
    02-21-2012
    Location
    Krsko, Slovenia
    MS-Off Ver
    Excel 2010
    Posts
    38

    Count sets of text

    Hello,

    I'm having problem with count function. I would like to count how many "sets" of text before blank coulmn is there in one row.

    In example: In row 1 there is text "SD" in columns A, B, C and then D is blank and then in E, F, G there is text "LD". So count or some other function should return number 2 because there are two sets of text - A,B,C and D,F,G

    Does anyone have some idea?


    Thank you and have a great day.

  2. #2
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,940

    Re: Count sets of text

    Pls attach a sample excel file with desired result with different examples
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  3. #3
    Registered User
    Join Date
    02-21-2012
    Location
    Krsko, Slovenia
    MS-Off Ver
    Excel 2010
    Posts
    38

    Re: Count sets of text

    I dont know why, but I cannot attach file, so I hope this table givs you an idea of what I'm looking for - numbers in last column, which represent how many sets of text, before there is a blank cell.

    SD SD SD SD SD 2
    SD SD SD SD SD SD 3
    0
    SD SD SD SD 4
    SD SD SD SD SD 1
    SD SD SD SD SD 3
    Last edited by Lynx2x; 01-31-2017 at 07:21 AM.

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

    Re: Count sets of text

    Try this...

    Data Range
    A
    B
    C
    D
    E
    F
    G
    H
    I
    1
    SD
    SD
    SD
    SD
    SD
    2
    2
    SD
    SD
    SD
    SD
    SD
    SD
    3
    3
    0
    4
    SD
    SD
    SD
    SD
    4
    5
    SD
    SD
    SD
    SD
    1
    6
    SD
    SD
    SD
    SD
    SD
    3
    7
    ----
    ----
    ----
    ----
    ----
    ----
    ----
    ----
    ----


    This array formula** entered in I1 and copied down:

    =SUM(IF(FREQUENCY(IF(A1:H1<>"",COLUMN(A1:H1)),IF(A1:H1="",COLUMN(A1:H1))),1))

    ** 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.

  5. #5
    Registered User
    Join Date
    02-21-2012
    Location
    Krsko, Slovenia
    MS-Off Ver
    Excel 2010
    Posts
    38

    Re: Count sets of text

    Thank you Tony Valko!! It works like a charm Also thanks to all the other guys that helped!

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

    Re: Count sets of text

    You're welcome. Thanks for the feedback!

  7. #7
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Count sets of text

    Unfortunately the attachment icon doesn't work at the moment. So, to attach an Excel file you have to do the following: Just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  8. #8
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Count sets of text

    assuming that your data start in A1, you could use tis array formula:

    =SUM(IF(FREQUENCY(IF(A1:I1="SD",COLUMN(A1:I1)),IF(A1:I1< > "SD",COLUMN(A1:I1))),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.
    Attached Files Attached Files

  9. #9
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Count sets of text

    Who spotted my "deliberate" mistake???

    =SUM(IF(FREQUENCY(IF(A1:H1="SD",COLUMN(A1:H1)),IF(A1:H1< > "SD",COLUMN(A1:H1))),1))
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    02-21-2012
    Location
    Krsko, Slovenia
    MS-Off Ver
    Excel 2010
    Posts
    38

    Re: Count sets of text

    I've looked at your solution and it works very good, but is it possible that function is not looking just for "SD", but any text? So insted of "SD" there could be "LD" or "SUNNYDAY" or whatever?

    Thank you for your very good and quick answer

  11. #11
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,798

    Re: Count sets of text

    Using Glenn's formula , try

    =SUM(IF(FREQUENCY(IF(A1:H1=M1,COLUMN(A1:H1)),IF(A1:H1<>M1,COLUMN(A1:H1))),1))

    where M1 (or cell of your choice) contains search value "SD", "LD", etc

  12. #12
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2024
    Posts
    6,176

    Re: Count sets of text

    You can use COUNTIFS function:

    =COUNTIFS(A1:H1,"SD",B1:I1,"<>SD")

  13. #13
    Registered User
    Join Date
    02-21-2012
    Location
    Krsko, Slovenia
    MS-Off Ver
    Excel 2010
    Posts
    38

    Re: Count sets of text

    John...that would be ok if in one row there would be only one type of text SD or LD,... But what if in one row there are different type of texts...

    Something like that:

    SD SD SD LD MM 2

    Phuocam....that would be a lot of countifs....I'm looking for function that is looking for any text....

  14. #14
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2024
    Posts
    6,176

    Re: Count sets of text

    for any text....

    =COUNTIFS(A1:H1,"?*",B1:I1,"")

+ 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 formula to count number of days between sets of dates?
    By barneysplash in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 02-16-2017, 06:22 AM
  2. [SOLVED] Formula to use to count the number of cells in a column which meet three sets of criteria
    By Dhabitude in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 12-11-2013, 11:22 AM
  3. [SOLVED] Trying to count the number of cells that meet two sets of Criteria
    By Pablo12 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 09-24-2013, 12:02 PM
  4. Count different sets of data with multiple variables
    By ransome in forum Excel General
    Replies: 2
    Last Post: 05-17-2010, 09:28 PM
  5. count cells with year sets in a column?
    By Brainless_in_Boston in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 05-04-2006, 05:15 PM
  6. [SOLVED] How to count sets of numbers
    By JimDandy in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 03-29-2006, 05:45 PM
  7. [SOLVED] Count rows that match 3 sets of criteria?
    By EricE in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-29-2005, 12:30 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