How to count the number of words in a Microsoft Excel file?

1

I need to count the total number of words in a MS Excel file. Usually, in MS Word or PowerPoint, it's either shown at the status bar or properties window. But in Excel, it's neither given anywhere.

Is there a solution?

Clicker

Posted 2018-01-05T11:37:24.743

Reputation: 200

1Cut and paste to another program? Export to CVS and pipe though wc ? – Hennes – 2018-01-05T11:40:31.887

What do you define as a word in an Excel file? Just normal words in cells containing text? Is a numerical value a word? How do you equate a formula to a word count? Do you need to count words in macros? Do you apply the same minimum character length rules as in text? – fixer1234 – 2018-01-06T23:03:03.173

Answers

2

You can create a macro for this:

Press ALT + F11 and Enter the below code.

Then Select the whole sheet run the Macro for a word count. You cna also Just select a section and Word Count Just that section.

Sub CountWords()
Dim MyRange As Range
Dim CellCount As Long
Dim TotalWords As Long
Dim NumWords As Integer
Dim Raw As String

Set MyRange = ActiveSheet.Range(ActiveWindow.Selection.Address)
TotalWords = 0
For CellCount = 1 To MyRange.Cells.Count
If Not MyRange.Cells(CellCount).HasFormula Then
Raw = MyRange.Cells(CellCount).Value
Raw = Trim(Raw)
If Len(Raw) > 0 Then
NumWords = 1
Else
NumWords = 0
End If
While InStr(Raw, " ") > 0
Raw = Mid(Raw, InStr(Raw, " "))
Raw = Trim(Raw)
NumWords = NumWords + 1
Wend
TotalWords = TotalWords + NumWords
End If
Next CellCount
MsgBox "There are " & TotalWords & " words in the selection."
End Sub

PeterH

Posted 2018-01-05T11:37:24.743

Reputation: 5 346

1

Try a formula like this:

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

Screenshot

Shane

Posted 2018-01-05T11:37:24.743

Reputation: 40

Not a bad result... Just needs some kind of IF test for empty cells, which currently count as one word. – BoffinBrain – 2018-01-05T15:22:53.543

This counts the words in a single cell. OP asked for the count of words in the whole workbook. – Bandersnatch – 2018-01-05T17:43:03.147

Use a formula like this: =SUM(IF(LEN(TRIM(A1:B5))=0,0,LEN(TRIM(A1:B5))-LEN(SUBSTITUTE(A1:B5," ",""))+1)). Then press Shift + Ctrl + Enter keys simultaneously to get the result – Shane – 2018-01-05T23:30:46.050