+ Reply to Thread
Results 1 to 4 of 4

COUNTIF giving wrong results

  1. #1
    Forum Contributor
    Join Date
    12-15-2009
    Location
    Herndon, VA
    MS-Off Ver
    Excel 2010
    Posts
    163

    COUNTIF giving wrong results

    I have the following formula in D2: =COUNTIF(B2:B15732,C2)

    In cell C2 I am referencing the word "Hardware" which occurs 43 times in column B when I do Ctrl + F. However, the COUNTIF function is returning 1 instead of 43. What could be wrong with this? There are multiple occurrences of "Hardware" not just one.

  2. #2
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: COUNTIF giving wrong results

    The cells have to contain exactly "hardware" - if you have leading or trailing spaces those won't be counted - what do you get with this version?

    =COUNTIF(B2:B15732,"*"&C2&"*")
    Audere est facere

  3. #3
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: COUNTIF giving wrong results

    Is the word Hardware appearing by itself? If there is a space before or after it, Countif will not find it unless you use a wildcard value such as:

    =COUNTIF(B2:B15732,"*hardware*") to check for any strings ending or beginning with your reference. =Trim() can help with this.

  4. #4
    Forum Contributor
    Join Date
    12-15-2009
    Location
    Herndon, VA
    MS-Off Ver
    Excel 2010
    Posts
    163

    Re: COUNTIF giving wrong results

    Quote Originally Posted by daddylonglegs View Post
    The cells have to contain exactly "hardware" - if you have leading or trailing spaces those won't be counted - what do you get with this version?

    =COUNTIF(B2:B15732,"*"&C2&"*")
    I considered that but I didn't think it would work because I was used to using the text box in the AutoFilter. I tried your suggestion and it worked. Thank you also to Daffodil.

+ 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. excel giving wrong answers
    By rizwan32 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-25-2013, 04:01 PM
  2. Countif results wrong
    By Markshr in forum Excel General
    Replies: 5
    Last Post: 02-08-2012, 02:56 AM
  3. formula giving wrong result sometimes?
    By lnjr in forum Excel General
    Replies: 2
    Last Post: 08-13-2010, 09:20 AM
  4. Very large complex workbook is now giving me the wrong results :(
    By S Davis in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 07-17-2006, 04:05 PM
  5. Please HELP!! Giving wrong answers!
    By lloydowens in forum Excel General
    Replies: 1
    Last Post: 03-16-2005, 10:34 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