Counting Lists

by Allen Wyatt
(last updated May 19, 2018)

1

Michele needs a way to count the number of bulleted lists or the number of numbered lists in a document. She wonders how this could be accomplished in Word.

This is a bit harder than one might imagine, the bottom line being that we can find no way to generate a count reliably. The reason for this may take a bit of explaining.

There are multiple ways you can add styles to your document. For instance, you could click on either the Number List or Bulleted List tools on the Home tab of the ribbon to convert the current paragraph (or paragraphs) to a list. You could also start typing and allow Word to detect (via AutoFormat As You Type) whether you are creating a numbered list or a bulleted list. You could even define and apply styles that designate what you want used as a list.

Regardless of the way you create your lists, Word associates a style with the paragraphs in the list. If you create and apply your own style, then that particular style is (of course) used. If you use the toolbar buttons or rely on AutoFormat to create the lists, then Word automatically applies the List Paragraph style. (Yes, it uses the exact same style regardless of whether it is a numbered or bulleted list.)

Since styles are associated with the list, you can quickly determine how many instances of the style are in use. All you need to do is to display the Styles task pane (display the Home tab of the ribbon and click the small icon at the bottom-right of the Styles group). Locate the style used for your lists, hover the mouse pointer over that style name, and then click the down-arrow that appears to the right of the name. You'll see something similar to one of the following appear:

  • Select All: (No Data)
  • Select All X Instance(s)

If what you see matches the first format, then select that option. When you hover over the style name and click the down-arrow again, what you see should match the second format.

You might think that this shows you the number of lists in your document. It doesn't; it only shows you the number of paragraphs formatted with this particular style. Thus, if you have a single list that is comprised of 6 items, then the style count returned will be 6. Thus, this approach—counting styles—doesn't provide a reliable way to determine a list count.

The other way you might consider is to use a macro to determine how many lists are in your document. Word maintains a Lists collection and makes it available to VBA. You can step through each list in the document and examine its ListType property. This property can actually be one of seven different values, as indicated by the following enumerations:

  • wdListBullet
  • wdListListNumOnly
  • wdListMixedNumbering
  • wdListNoNumbering
  • wdListOutlineNumbering
  • wdListPictureBullet
  • wdListSimpleNumbering

You can probably figure out what each of these lists types entails, but how they play out in reality can be a bit perplexing. As an example, consider the following macro:

Sub CheckLists()
    Dim oL As List
    Dim sMsg As String
    Dim J As Integer
    Dim K As Integer

    J = ActiveDocument.Lists.Count
    For Each oL In ActiveDocument.Lists
        K = K + 1
        oL.Range.Select

        sMsg = "This is list " & K & " of " & J
        sMsg = sMsg & " lists in the document." & vbCrLf & vbCrLf
        sMsg = sMsg & "This list is this type: "
        Select Case oL.Range.ListFormat.ListType
            Case wdListBullet
                sMsg = sMsg & "wdListBullet"
            Case wdListListNumOnly
                sMsg = sMsg & "wdListListNumOnly"
            Case wdListMixedNumbering
                sMsg = sMsg & "wdListMixedNumbering"
            Case wdListNoNumbering
                sMsg = sMsg & "wdListNoNumbering"
            Case wdListOutlineNumbering
                sMsg = sMsg & "wdListOutlineNumbering"
            Case wdListPictureBullet
                sMsg = sMsg & "wdListPictureBullet"
            Case wdListSimpleNumbering
                sMsg = sMsg & "wdListSimpleNumbering"
        End Select
        MsgBox sMsg
    Next oL
End Sub

If you have a document that contains lists and run this, it will select each list, in turn, and display a message box that shows what type of list Word thinks the selection represents. The problem is, if your text contains two lists interspersed by a paragraph or two of text, Word considers it a single list of the wdListMixedNumbering type. In other words, it doesn't accurately figure out what is a list and what isn't a list. This makes this particular approach unreliable for counting how many lists are in your document, although it is more accurate than using the count-the-styles approach.

The bottom line, as mentioned at the beginning, is that there is no way that we can determine to accurately count the number of bulleted and numbered lists in a document.

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 (13528) applies to Microsoft Word 2007, 2010, 2013, and 2016.

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

Creating a Drop Cap

Drop caps can be a nice finishing touch for some types of documents. Word allows you to create three types of drop caps, ...

Discover More

Managing Comments

If you frequently add comments to cells in a worksheet, Excel provides a variety of tools you can use to manage those ...

Discover More

Centering Information in Table Cells

One of the most common ways to format information in a table is to apply some sort of alignment to the contents of table ...

Discover More

Learning Made Easy! Quickly teach yourself how to format, publish, and share your content using Word 2013. With Step by Step, you set the pace, building and practicing the skills you need, just when you need them! Check out Microsoft Word 2013 Step by Step today!

More WordTips (ribbon)

Creating a List

You can format both numbered and bulleted lists very easily in Word. The tools available on the Home tab of the ribbon ...

Discover More

Understanding and Creating Lists

There are two types of common lists you can use in a document: bulleted lists and numbered lists. This tip explains the ...

Discover More

Removing a Bulleted or Numbered List

If you want to convert bulleted or numbered lists back to regular text (so they appear just like the rest of your ...

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}] 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 three minus 3?

2018-05-22 08:11:43

Ken Endacott

A better approach is to identify a paragraph’s List number, type of List and other paragraphs in the same List. The method works irrespective of the way the List was created or the styles used. This approach does not cover numbering from SEQ fields, for example in captions.

The following macro identifies the selected paragraph’s List and gives the option to highlight all paragraphs in the List, ignoring interspersed paragraphs. With the addition of an unhighlight option and a modal form, the macro is a very useful tool to help resolve numbering problems.

Sub ShowList()
' **** Find what List this paragrah belongs to and highlight all paragraphs in that list ****
Dim aRange As Range
Dim aList As List
Dim aPara As Paragraph
Dim j As Long
Dim m As Long
Dim LstDescr
LstDescr = Array( _
"has no bullets, simple, outline numbering and no caption numbering", _
"has listnum fields in body of paragraph", _
"is bulleted", _
"has simple numbering", _
"is an outline numbered list", _
"has mixed lists applied", _
"is picture bulleted", _
"has unknown numbering")

Set aRange = Selection.Range.Paragraphs(1).Range
aRange.Select

' determine if the paragraph is in a list
j = 1
m = -1
Do While j <= ActiveDocument.Lists.Count
Set aList = ActiveDocument.Lists(j)
For Each aPara In aList.ListParagraphs
If aPara.Range.InRange(aRange) Then
m = j
Exit Do
End If
Next aPara
j = j + 1
Loop
If m = -1 Then
MsgBox "Paragraph is not in a list"
Exit Sub
End If

j = aRange.Paragraphs(1).Range.ListFormat.ListType
If j < 0 Or j > 6 Then j = 7
If MsgBox("This paragraph is part of List" & Str(m) & " that " & LstDescr(j) _
& vbCrLf & vbCrLf & "Highlight all paragraphs in this List?" _
, vbYesNo) = vbYes Then
For Each aPara In ActiveDocument.Lists(m).ListParagraphs
aPara.Range.HighlightColorIndex = wdRed
Next aPara
End If
End Sub


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