count the words in excel code example Example: count words in a cell =LEN(TRIM(B5))-LEN(SUBSTITUTE(B5," ",""))+1