Resting Anchor

The Anchorage

Personal website of Gregory K. Maxey, Commander USN (Retired)

Reverse Number List
(A Microsoft Word Help & Tip page by Gregory K. Maxey)

DISCLAIMER/TERMS OF USE

The information, illustrations and code contained in my "Microsoft Word Tips" are provided free and without risk or obligation.

Click to acces PayPal Verification Service Click to acces PayPal Verification Service

However, the work is mine. If you use it for commercial purposes or benefit from my efforts through income earned or time saved then a donation, however small, will help to ensure the continued availability of this resource.

If you would like to donate, please use the appropriate donate button to access PayPal. Thank you!

Click to donate British Pound Sterling                   Click to donate US dollars                   Click to donate EU euros

This Microsoft Word Tips & Microsoft Word Help page provides a couple of macro solutions to apply reverse numbering to a selected list.

The text illustrated below provide an example list:

reverse number list 1

Select all list members including the final paragraph mark.

Site Note IconTip: Displaying non-printing characters will make it easier to ensure that you included the last paragraph mark in your selection.

reverse number list 2

Reverse Numbering with Fields

With the list members selected, execute the following VBA procedure:

VBA Script:
Option Explicit
Sub ReverseNumberList()
Dim i As Long
Dim listCount As Long
Dim Numrange As Range
Dim oTmpRng As Range
  Set Numrange = Selection.Range
  ActiveWindow.View.ShowFieldCodes = False
  Numrange.ParagraphFormat.TabStops.Add Position:=InchesToPoints(0.3)
  listCount = Numrange.Paragraphs.Count
  For i = 1 To listCount
    Set oTmpRng = Numrange.Paragraphs(i).Range
    If IsNumeric(oTmpRng.Characters(1)) Then
      On Error GoTo ErrHandler
      If InStr(oTmpRng.Fields(1).Code, "SEQ") > 0 Then
        oTmpRng.Fields(1).Delete
        oTmpRng.End = oTmpRng.Start + 2
        oTmpRng.Delete
      End If
    End If
Reentry:
    Set oTmpRng = Numrange.Paragraphs(i).Range
    oTmpRng.Collapse wdCollapseStart
    oTmpRng.InsertAfter "." & vbTab
    oTmpRng.End = oTmpRng.End - 2
    If i = 1 Then
      Numrange.Fields.Add oTmpRng, wdFieldSequence, "ReverseList \r1", False
    Else
      Numrange.Fields.Add oTmpRng, wdFieldSequence, "ReverseList", False
    End If
    oTmpRng.End = oTmpRng.End + 1
    Numrange.Fields.Add oTmpRng, wdFieldEmpty, , False
    oTmpRng.End = oTmpRng.End - 1
    oTmpRng.InsertAfter Text:="=" & listCount + 1 & "-"
    With Numrange.Paragraphs(i)
      .LeftIndent = InchesToPoints(0.3)
      .FirstLineIndent = InchesToPoints(-0.3)
    End With
  Next i
  ActiveWindow.View.ShowFieldCodes = False
  ActiveDocument.Fields.Update
  Exit Sub
ErrHandler:
  If Err.Number = 5941 Then
    Set oTmpRng = Nothing
    Resume Reentry
  Else
    MsgBox "Unknown error exiting this routine"
  End If
End Sub

Site Note icon See: Installing Macros for instructions on how to set up and use the macros provided in this Microsoft Word Help & Microsoft Word Tips page.

The method employs a SEQ field nested in a formula field to calculate and display the correct reverse numbering.

reverse number list 3

List with field code displayed

reverse number list 4
List with result displayed.

The second method is much simpler but is not well suited for re-ordering a list. Again, with the list members selected, run the following VBA procedure:

VBA Script:
Sub ReverseNumberListII()
Dim Numrange As Range
Dim numtable As Table
Dim numcolumn As Column
Dim tabwidth As Long
Dim i As Long
  Set Numrange = Selection.Range
  Set numtable = Numrange.ConvertToTable(Separator:=vbCr)
  tabwidth = PointsToInches(numtable.Columns(1).Width)
  Set numcolumn = Numrange.Tables(1).Columns.Add(BeforeColumn:=numtable.Columns(1))
  numcolumn.Width = InchesToPoints(0.5)
  numtable.Columns(2).Width = InchesToPoints(tabwidth - 0.5)
  For i = 1 To numcolumn.Cells.Count
    numcolumn.Cells(i).Range.InsertBefore (numcolumn.Cells.Count - i + 1) & "."
  Next i
  numtable.Borders.Enable = False
lbl_Exit:
  Exit Sub
End Sub

The method uses plain text numbering and a borderless table. The fine gridlines are shown only on the screen and can be toggled off with Tables>Hide Gridlines.

reverse number list 5

Site Note iconNote: Word MVP Cindy Meister provides a non-macro field solution to reverse numbering on her website at Reverse Numbering.

That's it! I hope you have found this tips page useful and informative.

Share

DISCLAIMER/TERMS OF USE

The information, illustrations and code contained in my "Microsoft Word Tips" are provided free and without risk or obligation.

Click to acces PayPal Verification Service Click to acces PayPal Verification Service

However, the work is mine. If you use it for commercial purposes or benefit from my efforts through income earned or time saved then a donation, however small, will help to ensure the continued availability of this resource.

If you would like to donate, please use the appropriate donate button to access PayPal. Thank you!

Click to donate British Pound Sterling                   Click to donate US dollars                   Click to donate EU euros

Search my site or the web using Google Search Engine

Google Search Logo