+ Reply to Thread
Results 1 to 4 of 4

COUNTIF - Problems specify the criteria as a range

  1. #1
    Registered User
    Join Date
    01-16-2012
    Location
    Bangkok
    MS-Off Ver
    Excel 2003
    Posts
    2

    COUNTIF - Problems specify the criteria as a range

    Hi I have a problem trying to apply the COUNTIF function.

    Let me explain my difficulties

    I have the following cells with data formatted like this:

    A
    Countries Selected
    Cambodia Thailand Philippines Laos Vietnam Belgium [A2]
    Vietnam Philippines Thailand Cambodia Laos [A3]
    Vietnam Cambodia Thailand Philippines Laos [A4]
    Cambodia Thailand Philippines Laos Vietnam [A5]
    Germany Thailand Cambodia Vietnam Laos Philippines [A6]

    B
    Countries
    Laos
    Cambodia
    Thailand

    C
    Number of Instances


    So basically, I need to count how many times a certain text string, corresponding to column B, (e.g. "Laos" ) occurs in ranges A2-6, and then output the result in column C.

    If I formulate the function in C2 as COUNTIF(A2:A6, "*Laos*), it gives me the correct value, but I want my criteria to reference the countries listed in column B.

    But my formula of COUNTIF(A2:A6, "*B2*) keeps giving me an error.

    Please help!
    Last edited by palmbum; 01-16-2012 at 06:12 AM. Reason: Problem Solved!

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,110

    Re: COUNTIF - Problems specify the criteria as a range

    Try:

    =COUNTIF(A$2:A$6, "*"&B2&"*")


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    01-16-2012
    Location
    Bangkok
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: COUNTIF - Problems specify the criteria as a range

    Quote Originally Posted by TMShucks View Post
    Try:

    =COUNTIF(A$2:A$6, "*"&B2&"*")


    Regards, TMS

    OMG... it worked! Gosh... this problem has been plaguing me for 3 days! Thank you so much!

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,110

    Re: COUNTIF - Problems specify the criteria as a range

    You're welcome.

+ 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.6.0 RC 1