The number of spaces in a cell is just =LEN(A1) - LEN(SUBSTITUTE(A1, " ", ""))

You sure that's what you want?