+ Reply to Thread
Results 1 to 4 of 4

Countif code that counts cells based on text string specified in a reference cell

  1. #1
    Registered User
    Join Date
    07-05-2012
    Location
    Rockland Mass.
    MS-Off Ver
    Excel 2007
    Posts
    6

    Countif code that counts cells based on text string specified in a reference cell

    Excel fans,
    I have a countif application problem that's illustrated in the attached file. It's intended to tally up the frequency of individual defect codes that appear (with other defect codes) in a column of raw data entry cells. I'm trying to write a countif formula that will count the cells in the raw data column that contain a specific data string that's contained in a reference cell to the left of the formulae. The problem is the targeted defect code (text string) could exist anywhere in the raw data cell. For example, the targeted string might be 'CL'. That string could be the only one in a given raw data cell or it could be embedded anywhere in a raw data cell amongst other defect strings. For example, a raw data cell might read, 'CL' or it might read 'CL,HAD,COH' which means the sample contained 3 different defects (from a vast array of possible defect codes) which were found and recorded in the order shown. However, the cell might instead read, 'HAD,CL,COH' or 'HAD,COH,CL'.
    A second problem is that there are similar codes, such as 'CLX' which contain the targetted code, such as 'CL'.
    I haven't been able to write the countif formula that counts the target stringe and only the target string regardless of where it appears in a raw data cell and doesn't mistake, for example the CL in CLX as target.

    The attached file illustrates the table, several flawed formulae and where they go wrong.
    drop test visual code tally snip-it.xlsx

    I would very much appreciate any help someone might be able to provide.
    Thank you,
    John Quinn

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Countif code that counts cells based on text string specified in a reference cell

    Are there always comma's between the various defect codes within a cell? Would a macro be an option?
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Countif code that counts cells based on text string specified in a reference cell

    Since you can have four different variations. Maybe try this formula see if it works

    =COUNTIF(drop1_data,"*,"&B34&",*")+COUNTIF(drop1_data,"*,"&B34)+COUNTIF(drop1_data,B34 &",*")+COUNTIF(drop1_data,B34)

  4. #4
    Registered User
    Join Date
    07-05-2012
    Location
    Rockland Mass.
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Countif code that counts cells based on text string specified in a reference cell

    JieJenn,
    Thank you very much for your quick and valuable recommendation.
    Gratefully,
    John Quinn

+ 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. Replies: 2
    Last Post: 11-18-2014, 06:26 AM
  2. [SOLVED] Code that Counts number of time string occurs in a column
    By adebayo_seun in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 07-05-2014, 11:40 AM
  3. Replies: 4
    Last Post: 01-31-2012, 01:08 PM
  4. macro that sorts and counts on the condition of a text string
    By shortman_alan in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-18-2008, 02:32 AM
  5. include string or text value in cell reference
    By nelly in forum Excel General
    Replies: 5
    Last Post: 06-06-2006, 07:40 PM

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