Please Note: This article is written for users of the following Microsoft Word versions: 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Word in Microsoft 365. If you are using an earlier version (Word 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Word, click here: Generating a Count of Word Occurrences.

Generating a Count of Word Occurrences

Written by Allen Wyatt (last updated May 9, 2026)
This tip applies to Word 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Word in Microsoft 365


1

As you are analyzing your documents, you may wonder if there is a way to create a count of the number of times a certain word appears in the document. Unfortunately, Word doesn't include such a feature, but there are a couple of things you can do.

First, if you want to know the number of times a specific word or phrase is used, you can follow these steps:

  1. Press Ctrl+H to display the Replace tab of the Find and Replace dialog box. (See Figure 1.)
  2. Figure 1. The Replace tab of the Find and Replace dialog box.

  3. In the Find What box, enter the word or phrase you want counted.
  4. In the Replace With box, enter ^&. This character sequence tells Word that you want to replace what you find with whatever you placed in the Find What box. (In other words, you are replacing the word or phrase with itself.)
  5. If you are searching for individual words, make sure you click the Find Whole Words Only check box.
  6. Click on Replace All. Word makes the replacements and shows you how many instances it replaced. That is the number you want.

This approach works great if you just have one or two words or phrases you want to know about. You can automate the process a bit by using a macro to search through the document and count for you. The following macro prompts the user for a word, and then counts the number of times that word appears in the document. It will continue to ask for another word until the user clicks on the Cancel button.

Sub FindWords()
    Dim sResponse As String
    Dim iCount As Integer

    ' Input different words until the user clicks cancel
    Do
        ' Identify the word to count
        sResponse = InputBox( _
          Prompt:="What word do you want to count?", _
          Title:="Count Words", Default:="")

        If sResponse > "" Then
            ' Set the counter to zero for each loop
            iCount = 0
            Application.ScreenUpdating = False
            With Selection
                .HomeKey Unit:=wdStory
                With .Find
                    .ClearFormatting
                    .Text = sResponse
                    ' Loop until Word can no longer
                    ' find the search string and
                    ' count each instance
                    Do While .Execute
                        iCount = iCount + 1
                        Selection.MoveRight
                    Loop
                End With
                ' show the number of occurences
                MsgBox sResponse & " appears " & iCount & " times"
            End With
            Application.ScreenUpdating = True
        End If
    Loop While sResponse <> ""
End Sub

If you want to determine all the unique words in a document, along with how many times each of them appears in the document, then a different approach is needed. The following macro will do just that.

Sub WordFrequency()
    Const maxwords = 5000          ' Maximum unique words allowed
    Dim SingleWord As String       ' Raw word pulled from doc
    Dim Words(maxwords) As String  ' Array to hold unique words
    Dim Freq(maxwords) As Long     ' Frequency counter for unique words
    Dim WordNum As Long            ' Number of unique words
    Dim ByFreq As Boolean          ' Flag for sorting order
    Dim ttlwds As Long             ' Total words in the document
    Dim Excludes As String         ' Words to be excluded
    Dim Punctuation As String      ' Punctuation marks
    Dim ans As String              ' How user wants to sort results
    Dim Found As Boolean           ' Temporary variables
    Dim J As Long
    Dim K As Long
    Dim L As Long
    Dim Temp As Long
    Dim tword As String
    Dim aword As Object
    Dim tmpName As String

    ' Punctuation marks
    Punctuation = ".,:;!?)}]'" & Chr(34) & ChrW(8221) & ChrW(8217)

    ' Excluded words
    Excludes = "[the][a][of][is][to][for][by][be][and][are]"
    Excludes = Excludes & "[but][or][because]"

    ' Find out how to sort
    Do
        ans = InputBox("Sort by WORD or by FREQ?", "Sort Order", "WORD")
        ans = UCase(Trim(ans))
        If ans = "" Then Exit Sub
    Loop Until ans = "WORD" Or ans = "FREQ"
    ByFreq = (ans = "FREQ")

    Selection.HomeKey Unit:=wdStory
    WordNum = 0
    ttlwds = ActiveDocument.Words.Count

    For Each aword In ActiveDocument.Words
        If WordNum = maxwords Then
            MsgBox "Too many words in document!", vbOKOnly
            Exit For
        Else
            SingleWord = Trim(LCase(aword))

            ' Get rid of trailing punctuation
            Do While (Len(SingleWord) > 0) And (InStr(Punctuation, Right(SingleWord, 1)) > 0)
                SingleWord = Trim(Left(SingleWord, Len(SingleWord) - 1))
            Loop

            ' Out of range?
            If Left(SingleWord,1) < "a" Or Left(SingleWord,1) > "z" Then SingleWord = ""

            ' On exclude list?
            If InStr(Excludes, "[" & SingleWord & "]") Then SingleWord = ""

            If Len(SingleWord) > 0 Then
                Found = False
                For J = 1 To WordNum
                    If Words(J) = SingleWord Then
                        Freq(J) = Freq(J) + 1
                        Found = True
                        Exit For
                    End If
                Next J
                If Not Found Then
                    WordNum = WordNum + 1
                    Words(WordNum) = SingleWord
                    Freq(WordNum) = 1
                End If
            End If
        End If
        ttlwds = ttlwds - 1
        StatusBar = "Remaining: " & ttlwds & ", Unique: " & WordNum
    Next aword

    ' Sort it into order
    For J = 1 To WordNum - 1
        K = J
        For L = J + 1 To WordNum
            If (Not ByFreq And Words(L) < Words(K)) _
              Or (ByFreq And Freq(L) > Freq(K)) Then K = L
        Next L
        If K <> J Then
            tword = Words(J)
            Words(J) = Words(K)
            Words(K) = tword
            Temp = Freq(J)
            Freq(J) = Freq(K)
            Freq(K) = Temp
        End If
        StatusBar = "Sorting: " & WordNum - J
    Next J

    StatusBar = False

    ' Write out the results
    tmpName = ActiveDocument.AttachedTemplate.FullName
    Documents.Add Template:=tmpName, NewTemplate:=False
    Selection.ParagraphFormat.TabStops.ClearAll
    With Selection
        For J = 1 To WordNum
            .TypeText Text:=Freq(J) & vbTab & Words(J) & vbCrLf
        Next J
    End With
    MsgBox "Found " & WordNum & " unique words", vbOKOnly, "Finished"
End Sub

When you open a document and run this macro, you are asked if you want to create a list sorted by word or by frequency. If you choose word, then the resulting list is shown in alphabetical order. If you choose frequency, then the resulting list is in descending order based on how many times the word appeared in the document.

While the macro is running, the status bar indicates what is happening. Depending on the size of your document and the speed of your computer, the macro may take a while to complete. (I ran it with a 719-page document with over 349,000 words and it took about five minutes to complete on a relatively slow computer.)

The macro, as shown above, will handle up to 5,000 unique words. If you need more words, change the maxwords constant at the beginning of the macro. You can even change maxwords to a lower value if you desire, as it may make the macro run just a bit quicker.

Note that the macro checks for trailing punctuation marks on words. This is because the Words collection includes trailing punctuation marks with a word. Since it you wouldn't want variations like "final" (no period) and "final." (with a period), it is best to strip the punctuation marks out.

There are also lines in the macro that construct the Excludes string. This string contains words that the macro will ignore when putting together the word list. If you want to add words to the exclusion list, simply add them to the string, between [square brackets]. Also, make sure the exclusion words are in lowercase.

Finally, note that this macro will work correctly for documents written in English. It may not work for documents written in other languages, especially languages that are right-to-left. I'm sure similar macros could be devised for other languages, but I have no way to test them should I even undertake to write one.

If you don't like to use macros for some reason (or your company doesn't allow you to use them), there are other programs you can use to create word counts. For instance, the NoteTab text editor (the "light" version can be downloaded free at https://www.notetab.com/) includes a feature that provides a word count. All you need to do is copy your entire document and paste it into NoteTab. Then, within NoteTab, choose Tools | Text Statistics | More. It presents an analysis of the word frequency, including percentages.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the WordTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (10761) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Word in Microsoft 365. You can find a version of this tip for the older menu interface of Word here: Generating a Count of Word Occurrences.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Subtotals Option Grayed Out

The Subtotals option on the Data menu is normally available for adding or removing subtotals to data tables. If the ...

Discover More

Complex Searches for Documents

When working with lots of documents, you may have need from time to time to discover which of those documents contain ...

Discover More

Understanding the Recycle Bin

The place where Windows stores files and other items you intend to delete is called the Recycle Bin. Understanding how to ...

Discover More

Discover the Power of Microsoft Office This beginner-friendly guide reveals the expert tips and strategies you need to skyrocket your productivity and use Office 365 like a pro. Mastering software like Word, Excel, and PowerPoint is essential to be more efficient and advance your career. Simple lessons guide you through every step, providing the knowledge you need to get started. Check out Microsoft Office 365 For Beginners today!

More WordTips (ribbon)

Creating a List of Cross-References

Cross-referencing has long been a capability in Word documents. You can easily add and remove cross-references but ...

Discover More

Creating a Transcription

In many offices, it is necessary to covert audio files (such as meeting recordings) into text. Some versions of Word have ...

Discover More

Word Count in Multiple Selections

Getting a word count for an entire document is easy. What you may not know is that some versions of Word can also provide ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 7 + 9?

2026-05-09 09:47:24

Arvilla Trag

The article on how to generate a count of word occurrences completely overlooked the fast and simple solution. Simply hit CTRL + F, enter the word you are searching for, and Word will tell you how many times it was found.


This Site

Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.

Videos
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.