Please Note: This article is written for users of the following Microsoft Word versions: 2007 and 2010. 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: Word Count for a Section.

Word Count for a Section

by Allen Wyatt
(last updated October 8, 2018)


One of the benefits of fields is that you can insert dynamic information within your document. When the field is updated, it is replaced with whatever information is current relative to the field in use. For instance, you can use the NumWords field to insert the number of words in the document. When the field is updated, it is replaced with however many words are then in the document.

If you want to find out the number of words in a section, and have it dynamically placed in a document, then you are out of luck. There is no field that will return this information. You can find it out manually by selecting the text in the section and then choosing the Word Count tool, but that obviously doesn't satisfy the desire to have a value that can be inserted into your document and automatically updated.

This means that you will need to rely on a macro to get the desired word count. If you just want to know the number of words in each section of your document, the following macro can be helpful.

Sub WordCount()
    Dim NumSec As Integer
    Dim S As Integer
    Dim Summary As String

    NumSec = ActiveDocument.Sections.Count
    Summary = "Word Count" & vbCrLf

    For S = 1 To NumSec
        Summary = Summary & "Section " & S & ": " _
          & ActiveDocument.Sections(S).Range.Words.Count _
          & vbCrLf

    Summary = Summary & "Document: " & _
    MsgBox Summary
End Sub

This simply steps through each section, determines the word count in that section, and displays the summary information in a message box. This does not provide a way to dynamically insert the information in the document, but it does provide an illustration of how you can find the word count of a single section.

A variation on the technique allows you to automatically insert the word count for a specific section at the location of a bookmark within your document. Let's say that you have a bookmarked called "WordCount" that you have defined. This bookmark specifies the place where you want the number of words in the second section of your document. The following macro will determine the word count for the specified section, and then insert the text at the location of the bookmark.

Sub InsertWordCount()
    Dim oRange As Word.Range
    Dim sBookmarkName As String
    Dim sTemp As String

    sBookmarkName = "WordCount"
    With ActiveDocument
        sTemp = Format(.Sections(2).Range.Words.Count, "0")
        Set oRange = .Bookmarks(sBookmarkName).Range
        oRange.InsertAfter Text:=sTemp
        .Bookmarks.Add Name:=sBookmarkName, Range:=oRange
    End With
End Sub

The macro could be easily called from other macros, such as one that runs when the document is opened, saved, or printed. That way the word count would be updated at all the normal times when a field is automatically updated.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (11098) applies to Microsoft Word 2007 and 2010. You can find a version of this tip for the older menu interface of Word here: Word Count for a Section.

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. ...


Deleting Footnotes and Endnotes

Deleting either footnotes or endnotes is a simple process. Just select the reference mark and delete it. Assuming you are ...

Discover More

Formatted Merging

When you use the mail-merge capabilities of Word, the information merged takes on the formatting of your source document, ...

Discover More

Selecting a Specific Cell in a Macro

Need to use a macro to select a specific cell in a different workbook? It's not as straightforward of a proposition as ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

More WordTips (ribbon)

Creating Many Index Entries at Once

Word makes it fairly easy to create an index. It is creating the index entries that can be tedious, especially if you ...

Discover More

Turning Off Hyphenation for Individual Words

Word does a semi-decent job when it comes to automatically hyphenating your documents. It even lets you exclude certain ...

Discover More

Generating a List of Unique Words

Need to grab a list of unique words appearing in a document? You can tap the power of VBA's Words collection to perform ...

Discover More

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

View most recent newsletter.


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}] 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 6 + 8?

2015-10-13 00:32:40

Ken Endacott

The following macros will count the number of words in each section. The count will exclude single special characters but will add a word count where there is more than one special character such as ###. If you compare with Word's word count you will see a significant difference.

Sub SectionWordCount()
Dim j As Long
Dim s As String
s = ""
For j = 1 To ActiveDocument.Sections.Count
s = s & CntWordsInRange(ActiveDocument.Sections(j).Range) & " in Section" & Str(j) & vbCrLf
Next j
MsgBox CntWordsInRange(ActiveDocument.Range) & " words in body of document" & vbCrLf & s
End Sub

Function CntWordsInRange(r As Range) As Long
Dim j As Long
Dim i As Long
i = 0
For j = 1 To r.Words.Count
Select Case Trim(r.Words(j))
Case Chr(1) To Chr(47), Chr(58) To Chr(96), Chr(123) To Chr(127)
Case Else
i = i + 1
End Select
Next j
CntWordsInRange = i
End Function

2015-09-03 19:35:27

Paul Perez-Jimenez

Has anyone solved the over count issue? I would really like for this macro to work.

2014-10-22 05:39:45


how do you stop the code from counting blan spaces

2014-07-11 17:47:06


The problem with the second macro is that the Count property of the Words object includes punctuation marks and paragraph marks as separate words.
You can get rid of the paragraph marks by using "sTemp = Format(.Sections(2).Range.Words.Count - .Sections(2).Range.Paragraphs.Count, "0")" But getting rid of the punctuation would be more difficult.

2014-05-31 07:18:15


Great tip, but can anyone please advise on what field should be used in the first macro to include footnotes.

2013-05-04 02:55:17


Ameet, I misread your mail. Your approach does indeed fix the problem. Thanks!

2013-05-04 02:47:50


Matt, I have the same problem. It appears as though the Count method counts punctuation characters as words.
Does anyone have any tips how to handle this?

2012-09-05 11:23:28


Hi Matthew,
Try changing the field to:
sTemp=Format(.Sections(2).Range.ComputeStatistics( wdStatisticWords), "0")

2012-04-11 05:39:12


This macro is neat, but the counts are quite inaccurate for the document I tried it on, in Word for Mac 2011. The toolbar shows a total word count of 2850, but ActiveDocument.Range.Words.Count gives 4051. The per-section counts are also about 25% over. I don't know why! I tried converting field codes to plain text, made no difference.

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.

Newest Tips

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.