Count number of characters in a range excluding spaces

Range Reference:
enter the range from which you want to count the number of characters
Formula:

=SUMPRODUCT(LEN(SUBSTITUTE(B5:B7," ","")))
=SUMPRODUCT(LEN(SUBSTITUTE(B5:B7," ","")))