+ Reply to Thread
Results 1 to 6 of 6

Counting numbers within a cell separated by comma

  1. #1
    Registered User
    Join Date
    03-30-2011
    Location
    Siberia
    MS-Off Ver
    Excel 2007
    Posts
    10

    Counting numbers within a cell separated by comma

    Hi, How can we count numbers in a cell that are separated by commas?

    Eg., 12,13,14,15,[16]

    The count result would be 4 in this case, excluding the one in the brackets.


    Thanks.

  2. #2
    Valued Forum Contributor
    Join Date
    05-23-2011
    Location
    Lahore PK
    MS-Off Ver
    Excel 2007, 2013
    Posts
    627

    Re: Counting numbers within a cell separated by comma

    hi hactic

    let your text is in cell # A1. try the follwing

    =LEN(A1)-LEN(SUBSTITUTE(A1,",","")) or

    =SUMPRODUCT(--LEN($A$1))-SUMPRODUCT(--LEN(SUBSTITUTE($A$1,",","")))

  3. #3
    Registered User
    Join Date
    03-30-2011
    Location
    Siberia
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Counting numbers within a cell separated by comma

    Hi thanks. I tried this but if you remove the brackets say from 12,13,14,[15] to 12,13,14,15, the result still remains 3 instead of incrementing to 4. Any fix for that?
    Last edited by hactic; 07-15-2011 at 01:39 AM.

  4. #4
    Valued Forum Contributor
    Join Date
    05-23-2011
    Location
    Lahore PK
    MS-Off Ver
    Excel 2007, 2013
    Posts
    627

    Re: Counting numbers within a cell separated by comma

    Hi hactic

    i am not clear what do u want. tell me what result u need in the follwing cases

    12,13,14,[15]
    12,13,14,15,
    12,13,14,15

  5. #5
    Registered User
    Join Date
    03-30-2011
    Location
    Siberia
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Counting numbers within a cell separated by comma

    Quote Originally Posted by Azam Ali View Post
    Hi hactic

    i am not clear what do u want. tell me what result u need in the following cases

    12,13,14,[15]
    12,13,14,15,
    12,13,14,15
    i want to count numbers that are separated by commas. so 12,13,14,15 = 4; 12,13,14,[15] = 3; 12,13,14,[15],16 = 4

    hope thats clear enough.

  6. #6
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    Office 2021
    Posts
    2,237

    Re: Counting numbers within a cell separated by comma

    Hello,

    Try this Array Formula. Confirmed with CONTROL+SHIFT+NTER, rather than just ENTER.

    =COUNT(--TRIM(MID(SUBSTITUTE(A1,",",REPT(" ",100)),100*ROW($A$1:$A$100)-99,100)))
    Regards,
    Haseeb Avarakkan

    __________________________________
    "Feedback is the breakfast of champions"

+ 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