Google Sheets – Conditional Formatting Based on Count of Spaces in Cell

google sheets

For Google Sheets, there's plenty on how to format based on length, and there's plenty on how to count spaces, but I'm struggling to combine the formula.

I understand the usage of ranges for formatting on length:

=len(A:A)>30

And for counting spaces:

=len(A1)-len(SUBSTITUTE(A1," ","")

But how do I apply ranges to the above so that it can be used in conditional formatting?

My goal is to format a cell red if there are more than N spaces in it.

Best Answer

Try using the formula:

=len($A1)-len(SUBSTITUTE($A1," ",""))>N

and the Range of the Conditional Format as A:A