Thread: [Solved] Dynamic table numbers
View Single Post
 
Old 06-17-2015, 03:57 AM
gmayor's Avatar
gmayor gmayor is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Provided the tables are in the body of the document and not in headers footers, text boxes etc, and are similar to that shown, then the following should work.

Code:
Sub NumberTables()
Dim oTable As Table
Dim i As Long, j As Long
Dim oCell As Range
    i = 1
    For Each oTable In ActiveDocument.Tables
        For j = 2 To oTable.Rows.Count
            Set oCell = oTable.Cell(j, 1).Range
            oCell.End = oCell.End - 1
            oCell.Text = i & Chr(46) 'This is what goes in the cells!
            i = i + 1
        Next j
    Next oTable
lbl_Exit:
    Set oTable = Nothing
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote