+ Reply to Thread
Results 1 to 3 of 3

Counting text only when specific text value appears in different column on same row.

  1. #1
    Registered User
    Join Date
    10-20-2016
    Location
    England
    MS-Off Ver
    2010
    Posts
    2

    Counting text only when specific text value appears in different column on same row.

    Hi,

    Thank you in advance for reading this and for any help.

    I would like to count the number of times a phrase appears in a cell when another cell within the corresponding row contains a specific value.
    For example, below is some data (it’s formatted as a table which is referenced as being ‘Table1’), I would like a formula that counts how many times the phrase “collecting comic books” appears in the same row as “Tim” (I want to know how many people called Tim collect comic books).

    (Note the issue this pertains to in real life the two columns are not next to each other)


    Col A Col B
    Name Hobbies
    Charlie Running, Collecting Comic Books, Football
    Charlie Ice-Skating, Playing Guitar
    James Ice-Skating, Football
    Rachel Collecting Comic Books
    Rachel Video Games, Football
    Rachel Video Games, Astronomy
    Max Football, Astronomy, Ice-Skating
    Max Running, Collecting Comic Books, Playing Guitar
    Ben Playing Guitar, Video Games
    Tim Astronomy, Ice-Skating
    Tim Collecting Comic Books, Ice-Skating
    Tim Collecting Comic Books



    I tried messing around with a formula that uses LEN but I’m kind of out of my depth with that one… I’ve tried to simplify things by using ‘text to columns’ as the values in the 'hobbies’ column are comma delimited. This way instead of having to look for a phrase within a cell I just need to find cells with a specific value.

    I tried using COUNTIFS and made a formula which looked like this:
    =COUNTIFS(Table1[Name],"Tim",Table1[[Hobbies_text to columns_first column]:[Hobbies_text to columns_last column]]," Collecting Comic Books")

    Here there are only two sets of range/criteria. Range One is the names column and the criteria is “Tim”. Range Two is the columns generated from my performing ‘text to columns’ on the hobbies column and the criteria is “Collecting Comic Books”. This doesn’t appear to work (perhaps because my second range includes empty cells?) and generates the #VALUE error.

    I would very much appreciate either a solution that can count phrases that appear in cells (no ‘text to columns’ required). Or a solution from someone was able to follow on what I’ve tried and failed to do with the text separated into columns.


    Thank you!

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,705

    Re: Counting text only when specific text value appears in different column on same row.

    You need to put asterisks around the text you are looking for, like this:

    "*Collecting Comic Books*"

    The asterisks are wildcard characters, which mean any or no characters before and after the text, so it enables you to do "contains".

    You are getting the #VALUE error as the ranges are not the same size - using the asterisks you will not need to do Text-to-Columns, so your formula would become:

    =COUNTIFS(Table1[Name],"Tim",Table1[Hobbies],"*Collecting Comic Books*")

    Hope this helps.

    Pete

  3. #3
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: Counting text only when specific text value appears in different column on same row.

    Try this
    =IF(A4="Tim",(IF(ISNUMBER(SEARCH("Collecting Comic Books",B4)),B4,"")))

    This will giv you the specific text infrom of every row if the Name is Tim,,,you may specify a cell reffrence where you you may create a validation list of Names.
    Teach me Excel VBA

+ 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] Counting the number of occurrences of specific text in a column
    By oneeasygeezer in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-23-2015, 11:11 AM
  2. Replies: 3
    Last Post: 01-07-2015, 03:55 AM
  3. shift cells in column 2 spaces to right if specific text appears in that column
    By hosburgh in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-13-2014, 12:46 PM
  4. Replies: 1
    Last Post: 12-10-2013, 05:23 PM
  5. Counting Text based on specific criteria in another column
    By djreddy in forum Excel Formulas & Functions
    Replies: 26
    Last Post: 08-26-2013, 09:35 AM
  6. Count the number of times a specific text appears in column D
    By jonvanwyk in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-04-2011, 02:02 PM
  7. Replies: 2
    Last Post: 01-20-2009, 08:24 AM

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