+ Reply to Thread
Results 1 to 4 of 4

countif with numerical wildcard

  1. #1
    Registered User
    Join Date
    09-02-2009
    Location
    Orlando, Florida
    MS-Off Ver
    Excel 2007
    Posts
    2

    countif with numerical wildcard

    I'm an intermediate user so haven't been able to follow some of the answers to similar questions already posted. I have data in a column as follows:

    1
    1
    2
    2367
    3
    8

    I want it to output how many times the character "2" appears, in this case, 2. Instead it keeps yielding 1, no matter what I try. The formula I've been working with is:

    =COUNTIF(O5:O150,"*"&"2"&"*")

    I've tried formatting the data as text or general. I've tried a million variations on whether the 2 and/or asterisks are in quotes, with and without ampersands.

    I'm guessing that it's not treating the digits in numbers as text. How do I fix this?

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: countif with numerical wildcard

    If you need to manipulate source you're left with SUMPRODUCT, eg:

    Please Login or Register  to view this content.
    this assumes 321 should count as 1 ... and 222 also counts only as 1 ... not clear ... if in fact 321 & 222 should yield 4 then:

    Please Login or Register  to view this content.

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: countif with numerical wildcard

    If you want to count all instances,

    =SUMPRODUCT(LEN(A1:A10)-LEN(SUBSTITUTE(A1:A10, 2, "") ) )

    If you want to count the cells where it appears,

    =SUMPRODUCT(--ISNUMBER(FIND(2, A1:A10)))
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Registered User
    Join Date
    09-02-2009
    Location
    Orlando, Florida
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: countif with numerical wildcard

    Fantastic, that works. Thank you!

    I should have specified: 2 will appear no more than once in a given cell, so the simpler versions you've given work beautifully.

    I've never used sumproduct, isnumber, or search before, so will have to check those out.

    Thanks very much!!

+ 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