+ Reply to Thread
Results 1 to 3 of 3

Thread: Best way to count variable number of text strings?

  1. #1
    Registered User
    Join Date
    01-25-2010
    Location
    Virginia
    MS-Off Ver
    Excel 2007
    Posts
    90

    Best way to count variable number of text strings?

    Attached is a sample file with 3 worksheets. The worksheet, Strings of Interest, has a list of strings that I need to get counts of from the data in the worksheet, Raw Data. I'd like to have a third worksheet like what I'm showing in this file as the sheet, Summary Data. The Summary Data sheet shows the number of occurrences of each String of Interest in the Raw Data sheet.

    I know how to create a helper column to count for each unique value, and to then sum all the occurrences, but that feels inefficient. My Raw Data sheet could have anywhere from 500 records, to 40,000 records. My "Strings of Interest" could change somewhat frequently over time. I have lots of files in which I need to do this same thing.

    What is a better/more efficient way to do what I'm trying to do?
    Last edited by SueWithQuestion; 08-22-2011 at 09:48 AM.

  2. #2
    Forum Guru NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    32,640

    Re: Best way to count variable number of text strings?

    If you remove the = signs from the column A entries, then in B2 enter:

    =COUNTIF('Raw Data'!A:A,"*"&A2&"*")

    copied down to easily get count of each item
    Microsoft MVP - Excel

    Where there is a will there are many ways. Pick One!


    Please read the Forum Rules

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

    Preferred Charities: Lupus Canada and Sick Kids Foundation.
    Feel Free to Donate if you want to, for the assistance you received today.

  3. #3
    Cheeky Forum Moderator Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2003, 2007, 2010
    Posts
    3,712

    Re: Best way to count variable number of text strings?

    Using your sample workbook...on the Summary Data sheet

    This regular function begins the list of "Strings of Interest"
     
    A2: =IF(COUNTA('Strings of Interest'!$A:$A)>=ROWS('Summary Data'!$2:2),
    INDEX('Strings of Interest'!$A:$A,ROWS('Summary Data'!$2:2)),"")
    and this regular formula returns the count of the Col_A string from the Raw Data sheet
     
    B2: =IF(A2<>"",COUNTIF('Raw Data'!$A:$A,"*"&A2),"")
    Copy those formulas down as far as you need.

    Is that something you can work with?
    Regards,

    Ron
    Microsoft MVP - Excel
    (Oct 2006 - Sep 2012)

    Click here to see the Forum Rules

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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.2.0