Forum Discussion

J_Uys123's avatar
J_Uys123
Copper Contributor
Aug 13, 2019
Solved

Excel COUNTIF function not counting correctly

I've been using a sheet for a long time. Suddenly today, a simple COUNTIF function doesn't work any more. The formula is as simple as they get: =COUNTIF(AC23:SZ23,"L"). There are numerous 'L's in the row, yet it returns 1.

 

There are many other such countif functions counting data in the same row, such as =COUNTIF(AC23:SZ23,"FDO"), which works perfectly. It looks at exactly the same data set, formatted in exactly the same manner. The cells are all 'general'.

 

What can be wrong?

  • There might be L’s with leading and trailing spaces. Try this:
    =SUMPRODUCT(—(TRIM(AC23:SZ23)=“L”))

4 Replies

  • Mercyjay's avatar
    Mercyjay
    Copper Contributor
    My counties not counting
    I used = counties(Gender, male, GPA,''>''&3.2) I have been working on it for some hours I could not get what I want?
  • Twifoo's avatar
    Twifoo
    Silver Contributor
    There might be L’s with leading and trailing spaces. Try this:
    =SUMPRODUCT(—(TRIM(AC23:SZ23)=“L”))
    • J_Uys123's avatar
      J_Uys123
      Copper Contributor

      Twifoo 

       

      This formula works, thanks.

       

      I checked, and there were training spaces behind the 'L's. Upon investigation it turns out that my staff member typed in 'leave' and then corrected it afterwards. Excel let the word 'leave' reappear when he tried typing in 'L', so he made a space to get the 'L'. And that 'incapacitated' my formula.

Resources