+ Reply to Thread
Results 1 to 6 of 6

Get a count of multiple values from a range within a single cell?

Hybrid View

  1. #1
    Registered User
    Join Date
    03-09-2015
    Location
    US
    MS-Off Ver
    2010
    Posts
    26

    Get a count of multiple values from a range within a single cell?

    I have a data set and can identify the cells that contain a value from the range, but sometimes a cell will contain multiple values from the range. I'd like to get a count of each occurrence.

    My current formula to identify cells is:
    =IF(SUMPRODUCT(COUNTIF(A2,"*"&NamedRange&"*"))>0,"Yes","No")
    For example, if a cell contains text as follows:
    AB01, AB02, AB03

    And each of those values is in my named range, my current formula just counts the cell once. I'd like to return the number of instances the cell contains something from the named range. In this case it would return 3.

    I saw a lot of example functions with subtitute and len, but I'm doing it wrong. My named range is bigger and has longer names so I'd prefer not type them in or look for them individually.

  2. #2
    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,290

    Re: Get a count of multiple values from a range within a single cell?

    =SUMPRODUCT(LEN(A2)-LEN(SUBSTITUTE(A2,Named Range,"")))

    might work. But I'm not confident. if not, please post a sample sheet (not a picture of one)

    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

  3. #3
    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
    28,402

    Re: Get a count of multiple values from a range within a single cell?

    Try

    =SUMPRODUCT(--(ISNUMBER(SEARCH(NamedRange,A2))))

  4. #4
    Forum Expert Tsjallie's Avatar
    Join Date
    09-15-2012
    Location
    NL
    MS-Off Ver
    2010, 2013, 2016
    Posts
    2,077

    Re: Get a count of multiple values from a range within a single cell?

    With these data
    Count.JPG
    this formula counts all the codes (as long as they are separated by commas)
    Formula: copy to clipboard
    =SUMPRODUCT(--(LEN(C1:H1)-LEN(SUBSTITUTE(C1:H1,",",""))=0),--(C1:H1<>""))+
    SUMPRODUCT(--(LEN(C1:H1)-LEN(SUBSTITUTE(C1:H1,",",""))>0),LEN(C1:H1)-LEN(SUBSTITUTE(C1:H1,",",""))+1)
    Cheers!
    Tsjallie




    --------
    If your problem is solved, pls mark the thread SOLVED (see Thread Tools in the menu above). Thank you!

    If you think design is an expensive waste of time, try doing without ...

  5. #5
    Registered User
    Join Date
    03-09-2015
    Location
    US
    MS-Off Ver
    2010
    Posts
    26

    Re: Get a count of multiple values from a range within a single cell?

    Oh you guys are fast.

    These work. Thank you!
    Attached Files Attached Files
    Last edited by ziggyztz; 05-04-2017 at 04:20 PM.

  6. #6
    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
    28,402

    Re: Get a count of multiple values from a range within a single cell?

    This returns your results


    =SUMPRODUCT(--(ISNUMBER(SEARCH(NamedRange,A2))))
    Attached Files Attached Files

+ 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. How to count a range of values in a single cell?
    By nyc_doc in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 03:05 PM
  2. [SOLVED] How to count a range of values in a single cell?
    By nyc_doc in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 10:05 AM
  3. How to count a range of values in a single cell?
    By Gary's Student in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-06-2005, 07:05 AM
  4. [SOLVED] How to count a range of values in a single cell?
    By Gary's Student in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 09-06-2005, 04:05 AM
  5. [SOLVED] How to count a range of values in a single cell?
    By nyc_doc in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 01:05 AM
  6. How to count a range of values in a single cell?
    By nyc_doc in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 AM
  7. [SOLVED] How to count a range of values in a single cell?
    By nyc_doc in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 11:05 PM
  8. [SOLVED] How to count a range of values in a single cell?
    By nyc_doc in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-02-2005, 08:05 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