+ Reply to Thread
Results 1 to 10 of 10

Dynamic COUNTIF function looking for text value in comma-separated string

  1. #1
    Registered User
    Join Date
    07-05-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Dynamic COUNTIF function looking for text value in comma-separated string

    Hi everyone,

    I'm not very savvy with excel, so I think this should be an easy fix for one of you experts.

    I have a database full of peoples' personal interests (i.e. Agriculture, Finance, Technology, etc.) and they are allowed to select as many interests as they want.

    When importing this data, their interests show up in one cell, separated by commas. So if Person A chose that they were interested in Agriculture and Technology, it would show up in the cell as "Agriculture, Technology".

    I have column headings for each of the particular fields and want to create a dynamic COUNTIF function that will search for how many times each interest shows up in a range of date. I'd like to be able to drag this function across my spreadsheet so it searches the entire range based on my different column headings.

    I'm searching the G column in another sheet for "Agriculture" (which is in B32), but it's only returning the number of cells that equal EXACTLY "Agriculture". I want the search to count if the cell contains "Agriculture" anywhere within the comma-separated cell.

    =COUNTIF('OAP talent pool'!G4:G2537,"=" & B32)

    Thanks!

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

    Re: Dynamic COUNTIF function looking for text value in comma-separated string

    Try it like this...

    =COUNTIF('OAP talent pool'!G4:G2537,"*"&B32&"*")

    The * are wildcards.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Registered User
    Join Date
    07-05-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Dynamic COUNTIF function looking for text value in comma-separated string

    That's it, thanks a ton Tony!

  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: Dynamic COUNTIF function looking for text value in comma-separated string

    You're welcome. Thanks for the feedback!

  5. #5
    Registered User
    Join Date
    12-08-2016
    Location
    Kenya
    MS-Off Ver
    MS Office Standard 2013
    Posts
    2

    Re: Dynamic COUNTIF function looking for text value in comma-separated string

    Hey, what if I wanted to use thw word "Agriculture" and not cell B32 what will the formulae look like?

    I have tried =COUNTIF('OAP talent pool'!G4:G2537,"*"&Agriculture&"*") but it doesn't work.

  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: Dynamic COUNTIF function looking for text value in comma-separated string

    Like this...

    =COUNTIF('OAP talent pool'!G4:G2537,"*Agriculture*")

  7. #7
    Registered User
    Join Date
    12-08-2016
    Location
    Kenya
    MS-Off Ver
    MS Office Standard 2013
    Posts
    2

    Re: Dynamic COUNTIF function looking for text value in comma-separated string

    That worked, thank you.

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

    Re: Dynamic COUNTIF function looking for text value in comma-separated string

    You're welcome. Thanks for the feedback!

  9. #9
    Registered User
    Join Date
    11-27-2017
    Location
    Surrey, England
    MS-Off Ver
    2013
    Posts
    1

    Re: Dynamic COUNTIF function looking for text value in comma-separated string

    Hi guys, i'm having some issues implementing the ideas on this thread to my work. I have 2 criteria, camera number and event type. I need to know how many different cameras have been used for each event type. The camera number is a text field and uses commas as it's very likely more than 1 camera being used. I trouble i am having is that I have cameras called S1 and also 1, so the * on the "*1*" formula is bringing in camera number 1 and S1. Similarly this will apply for cameras 1 and 10 etc etc. I've inserted a snapshot below. Any help would be warmly received.

    Untitled.png
    Attached Images Attached Images

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

    Re: Dynamic COUNTIF function looking for text value in comma-separated string

    thorned,
    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)

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