Count words in a range of cells or columns in Excel and Google Sheets

={SUM(IF(LEN(TRIM(A2:A5))=0,0,LEN(TRIM(A2:A5))-LEN(SUBSTITUTE(A2:A5," ",""))+1))}

A:2:A5 = Range

ArrayFormula use "Ctrl+Shift+Enter"

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