شنبه یازدهم مرداد ۱۳۹۹ - 15:0 - حسين حسين پور -
This code is one of my useful macro codes list which I use in my work and it can help you to count all the words from a worksheet.
Sub Word_Count_Worksheet()
Dim WordCnt As Long
Dim rng As Range
Dim S As String
Dim N As Long
For Each rng In ActiveSheet.UsedRange.Cells
S = Application.WorksheetFunction.Trim(rng.Text)
N = 0
If S <> vbNullString Then
N = Len(S) - Len(Replace(S, " ", "")) + 1
End If
WordCnt = WordCnt + N
Next rng
MsgBox "There are total " & Format(WordCnt, "#,##0") & " words in the active worksheet"
End Sub
When you run it, it will show a message box with the number of words you have in the active worksheet.