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