Question : =countif(trim(a1:a100), "=red") does not work.  How to fix this without vba?

Cells a1:a100 often have trailing spaces because they are imported from a web page.  (geeesss I hate this, it happens all the time.)

I usually use vba to fix the cell's directly, but I wonder if anyone knows how to code the formula directly into  a single cell. (I also don't want to create column like b1:b100 which trims the first column)

I tried =countif(trim(a1:a100), "=red")  but it gives a syntax error even with control shift enter.

Using =countif(a1:a100, "=red*")  is closer, but it counts cells like "redo" and "redone".

Any bright ideas?

Answer : =countif(trim(a1:a100), "=red") does not work.  How to fix this without vba?

rberke,
The following array formula also works with sufficient discrimination:
=SUM(IF(TRIM(A1:A100)="red",1,0))       array formula, so remember to CTRL + Shift + Enter
Brad
Random Solutions  
 
programming4us programming4us