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


Changing Your Company Name

The installation process for Office and Excel allows you to specify a company name. If your company name later changes, ...

Discover More

Creating a Shortcut for Pasting Values

Excel's Paste Special command is used quite a bit. If you want to create some shortcuts for the command, here's some ways ...

Discover More

Placing WordArt Over Graphics

WordArt is a program that allows you to insert fancily formatted text, as a graphic, in your document. If you want your ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More WordTips (ribbon)

Changing the Document Inspector's Comment Name

The Document Inspector can be a great tool when you want to prepare your document to be shared with others and you want ...

Discover More

Mass Search and Replace

If you need to change information in dozens or even hundreds of documents, the task can seem insurmountable. Here's a way ...

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

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 4 + 0?

2019-10-14 14:48:57

Michael Tollefson

This old 2007 Knowledge Base article seems still germane: I used your tip, the KB article, and document variables to get what I needed. Thanks.

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.