Forum Discussion

xtine17's avatar
xtine17
Copper Contributor
Mar 29, 2023

COUNTIF not counting unless I specifically type criteria out?

I am trying to use a COUNTIF function to count how many times names appear throughout the worksheet tabs.  The COUNTIF function works correctly if I physically type out "Smith" for criteria, but not if I use the cell reference with the last name in it?

 

For Example:

Column B has the reference of last names I am using in my COUNTIF function.  B2 has the first name I am referencing (Smith).  If I type ="COUNTIF('SHEET 1'!A$4:E$20, B2), 0 result populates.  If I type the same formula but as ="COUNTIF('SHEET 1'!A$4:E$20, "Smith"), the correct result populates.

 

I want to copy this formula down to repeat for over 100 last names... It would take forever to hand type each last name as I copy down the formula.  Any tips?

6 Replies

    • xtine17's avatar
      xtine17
      Copper Contributor
      Just checked, no spaces in the data reference column. Could it be because out of all the ranges COUNTIF is searching for, this spreadsheet has multiple cells with multiple last names listed (for example 1 cell will say "Smith, Jones, Parker") ?

Resources