countif not working when trying to find the word "true"

Berrett

Board Regular
Joined
Aug 6, 2004
Messages
249
I have a formula that looks like this:

=C2&" ("&COUNTIF(C4:C212,"true")&")"

However the countif formula is returning zero no matter how many times the word "true" occurs in the references cells. This has something to do with the word "true" itself because if I change the word to something else (like "donkey") then it will count appropriately.

However, I have 24 sheets of data that all have the word "true" in relevant cells. I would rather not find/replace all of the "true" values and exchange them for some other word. Also, the word true has face value in this particular project.

Does anyone know why the formula breaks when it searches for that word?

-- Other info: I'm using data that has been exported from SPSS's text analysis software. I can't see any evidence that the cells have formatted in any weird way, but I thought it was worth mentioning.
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Is it possible they contain leading/trailing spaces? Try:
=COUNTIF(C4:C212,"*true*")

Alternatively, you could TRIM the cell in C4:C212 first
 
Upvote 0
Thanks Jen - it said that the formula I typed contained an error.

Just to clarify: The values in the cells of the worksheet containe the word "true", no quotation marks.
 
Upvote 0
Neil - That did it! Thank you. I checked for leading and trailing spaces and didn't see any, so honestly, I'm not sure why it's working now. But it is.

Thank you for your help.
 
Upvote 0
Neil - That did it! Thank you. I checked for leading and trailing spaces and didn't see any, so honestly, I'm not sure why it's working now. But it is.

Thank you for your help.

Glad it worked. You can check for leading/trailing spaces by testing the length, i.e =LEN(A1)
 
Upvote 0

Forum statistics

Threads
1,224,505
Messages
6,179,152
Members
452,891
Latest member
JUSTOUTOFMYREACH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top