Count number of words in a cell in Excel and Google Sheets

=LEN(A2)-LEN(SUBSTITUTE(A2," ",""))+1

=IF(LEN(TRIM(A2))=0,0,LEN(TRIM(A2))-LEN(SUBSTITUTE(A2," ",""))+1)

A2 = data cell

Check below for a detailed explanation with pictures and how to use formulas in Excel and Google Sheets.