+ Reply to Thread
Results 1 to 16 of 16

How to count values separated by a comma

  1. #1
    Registered User
    Join Date
    11-18-2013
    Location
    Bulgaria
    MS-Off Ver
    Excel 2007
    Posts
    7

    How to count values separated by a comma

    Hello to All,

    I have the following case which are trying to solve for some time. Can anyone help me?

    I have one column with three rows (three cell's), in which cell the numbers are separated by commas. I want to count how many numbers are repeated, for this example, only fours(4). In this case they have to be five(5). I need a formula.

    4, 56, 87, 21, 4, 44
    23, 56, 4, 85, 96, 14
    24, 57, 4, 56, 89, 4

    Thank you in advance!

  2. #2
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: How to count values separated by a comma

    Specifically what value should the formula return??
    Gary's Student

  3. #3
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: How to count values separated by a comma

    for 1 and 2 digit numbers as per your example with H1 containing the number you want to count
    =SUMPRODUCT(((LEN(","&A1:A3&",")-LEN(SUBSTITUTE(","&A1:A3&",",","&$H$1&",","")))/IF(LEN(H1)=2,4,3)))
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  4. #4
    Registered User
    Join Date
    11-18-2013
    Location
    Bulgaria
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: How to count values separated by a comma

    it dosen't work!
    Last edited by PlamSa; 11-18-2013 at 04:22 PM.

  5. #5
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: How to count values separated by a comma

    Hi,

    You still haven't told us what the result should be?

    And instead of pictures, could you please consider posting actual spreadsheets?

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  6. #6
    Registered User
    Join Date
    11-18-2013
    Location
    Bulgaria
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: How to count values separated by a comma

    to count how many times in some database is repeated specific number ( in this case number 4 is repeated 5 times)




    http://pastelink.me/dl/caf82d
    Last edited by PlamSa; 11-18-2013 at 04:00 PM.

  7. #7
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: How to count values separated by a comma

    And did you follow Martin's instructions? Why didn't his solution work? What result did you get?

    Please stop posting pictures! Spreadsheets, please - not pictures!

    Regards

  8. #8
    Registered User
    Join Date
    11-18-2013
    Location
    Bulgaria
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: How to count values separated by a comma

    Here is simple Spreadsheet,

    http://pastelink.me/dl/4580da

    Regards,

  9. #9
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: How to count values separated by a comma

    Ok,

    I think you need to remove the spacing first for his solution to work:

    =SUMPRODUCT(((LEN(","&SUBSTITUTE(A1:A3," ","")&",")-LEN(SUBSTITUTE(","&SUBSTITUTE(A1:A3," ","")&",",","&$H$1&",",""))))/IF(LEN(H1)=2,4,3))

    A slightly different approach, though one which will work on strings of any length, is this array formula (again, with the desired match, e.g. 4, in cell H1):

    =SUM(--(IFERROR(--TRIM(MID(SUBSTITUTE(TRANSPOSE(A1:A3),",",REPT(" ",89)),89*(ROW(INDIRECT("1:"&1+MAX(LEN(A1:A3)-LEN(SUBSTITUTE(A1:A3,",","")))))-1)+1,89)),"")=$H$1))

    Regards

  10. #10
    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: How to count values separated by a comma

    Try this

    =SUM(COUNTIF(A1:A3,"*4"),COUNTIF(A1:A3,"*4*"))
    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

  11. #11
    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
    52,926

    Re: How to count values separated by a comma

    Please do not upload a picture of your file...rather, upload a sample of your workbook, showing what data you are working with, a few samples of your expected outcome is (manually entered is ok) and how you arrived at that. (exclude sensitive info). 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)

    Also, post your file here, not all members are able OR willing to go to file-hosting sites
    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

  12. #12
    Registered User
    Join Date
    11-18-2013
    Location
    Bulgaria
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: How to count values separated by a comma

    OK, Thank you, FDibbins.

    But I have some questans:

    1. how to uloade only simple excel file here in my post;
    2. and how to post my file here, not all members are able OR willing to go to file-hosting sites?

    Than you in advance,

    Regards,
    Last edited by PlamSa; 11-18-2013 at 06:49 PM.

  13. #13
    Registered User
    Join Date
    11-18-2013
    Location
    Bulgaria
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: How to count values separated by a comma

    Hello, AlKey,

    it works in this way,

    but if I put large database it dosen't. Here I upload a large file. I try some other things but isn't work.

    http://pastelink.me/dl/a3e892
    Last edited by PlamSa; 11-18-2013 at 06:54 PM.

  14. #14
    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: How to count values separated by a comma

    Here is something you may want to consider. I think the best and fastest solution to deal with this is to use Text To Columns feature in excel.

    Please see attached file and let me know what you think. Splitting cells makes very easy to accomplish this task.
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    11-18-2013
    Location
    Bulgaria
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: How to count values separated by a comma

    Thank you, AlKey,

    This is most simple and easily way to solve this case.

    It is SOLVED

    Thank you

  16. #16
    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: How to count values separated by a comma

    You're welcome and thanks for the feedback!

+ 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. Count number of occurrences separated by comma
    By Niclal in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-23-2013, 03:39 AM
  2. count of comma separated values
    By bujji1305 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-01-2012, 07:33 PM
  3. Replies: 5
    Last Post: 02-05-2012, 04:44 PM
  4. count comma separated information
    By fjosef87 in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 04-04-2010, 10:47 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