+ Reply to Thread
Results 1 to 9 of 9

Formula to count values in single cell separated by commas

  1. #1
    Registered User
    Join Date
    08-21-2013
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    36

    Formula to count values in single cell separated by commas

    Is it possible to have a formula that can count the amount of values in a single cell?

    EG:

    Cell A2 contains "C1, C2, C3, D1, D4, D5"
    is there a formula i can put in Cell B2 that will count how many values there are in A2?

    so cell B2 would then say "6"

    Every value is separated by a comma and a space exactly as above (if that helps)

    thanks!

  2. #2
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Formula to count values in single cell separated by commas

    Please try this formula:

    =LEN(A2)-LEN(SUBSTITUTE(A2," ",""))+1
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  3. #3
    Forum Expert RobertMika's Avatar
    Join Date
    06-22-2009
    Location
    Haverhill, UK
    MS-Off Ver
    Excel 2003-13
    Posts
    1,530

    Re: Formula to count values in single cell separated by commas

    =LEN(A2)-LEN(SUBSTITUTE(A2,",",""))+1
    or
    LEN(TRIM(A2))-LEN(SUBSTITUTE(TRIM(A2),",",""))+1
    (in case of trailing or leading spaces)
    If you are http://www.excelforum.com/image.php?type=sigpic&userid=125481&dateline=1392355029happy with the results, please add to the contributor's
    reputation by clicking the reputation icon (star icon).




    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.
    To undo, select Thread Tools-> Mark thread as Unsolved.
    http://www.excelaris.co.uk

  4. #4
    Registered User
    Join Date
    08-21-2013
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    36

    Re: Formula to count values in single cell separated by commas

    Thanks both of you! i thought i had marked this as solved and had replied but it appears to not have worked?

    Thanks Robert, in my case there will definitely not be any trailing or leading spaces because the step beforehand is a macro that sets up the values in this way.

    either way, they both work, thanks!

  5. #5
    Forum Expert RobertMika's Avatar
    Join Date
    06-22-2009
    Location
    Haverhill, UK
    MS-Off Ver
    Excel 2003-13
    Posts
    1,530

    Re: Formula to count values in single cell separated by commas

    You are weclcome.
    Reputation will be welcomed as well.

  6. #6
    Registered User
    Join Date
    10-08-2013
    Location
    N. Sembilan, Malaysia
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Formula to count values in single cell separated by commas

    OMG thanks for this!

  7. #7
    Registered User
    Join Date
    10-16-2014
    Location
    India
    MS-Off Ver
    2013
    Posts
    1

    Re: Formula to count values in single cell separated by commas

    Most appropriate would be
    =IF(TRIM(A2)="",0,LEN(TRIM(A2))-LEN(SUBSTITUTE(TRIM(A2),",",""))+1)

  8. #8
    Registered User
    Join Date
    06-24-2017
    Location
    new jersey
    MS-Off Ver
    MS Office 365 Pro Plus
    Posts
    1

    Re: Formula to count values in single cell separated by commas

    I have a similar item, but the values are separated by a semicolon. The final value also has a semicolon, which is adding an extra digit to the sum. Any help? Thanks!

  9. #9
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,602

    Re: Formula to count values in single cell separated by commas

    Tenjika,
    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.
    Ben Van Johnson

+ 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] How do I combine multiple lines of information into a single cell, separated by commas?
    By ilostar in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-22-2012, 11:48 AM
  2. [SOLVED] Values separated by Commas - want in separate columns, cells from original cell
    By schmidt62 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-03-2012, 02:50 PM
  3. Replies: 5
    Last Post: 06-05-2012, 03:32 PM
  4. Find a Value In A Table of Cell Each With More Than 2 Values Separated By Commas
    By Misha322 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-28-2012, 02:42 PM
  5. Options marked with an "X" listed in a single cell separated by commas
    By jpecor2 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-13-2011, 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