Forum Discussion
laws120
Feb 24, 2025Copper Contributor
Counting cells containing spaces
I'm trying to count a column of cells which contain a string of numbers, dashes and spaces. I would like to count the cells which only contain spaces. I've tried: =COUNTIFS(C3:C10000,"*",C3:C10000,...
SergeiBaklan
Feb 25, 2025Diamond Contributor
Both formulae shall work if you'd like to count cells with one space " ". If to count cells with any number of spaces, e.g. " ", " ", etc
=COUNTIF(C3:C10000," *")
If to count as well cells with empty strings "" and blank cells, when as suggested with SUMPRODUCT.
m_tarler
Feb 25, 2025Bronze Contributor
I though of countif with " *" but was concerned because that would also count any cell with text that starts with a space (e.g. " - - - "). I was also surprised you didn't submit a REGEXP solution. I really need to learn those expression rules better ....
- SergeiBaklanFeb 25, 2025Diamond Contributor
You are right, " *" doesn't work in such case. As for regex, equivalent of SUMPRODUCT
=SUM(--REGEXTEST( C3:C10000, "^\s*$"))