If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Simple way to number the rows in a table?
I have a document containing descriptions of parts. Each part section
contains a tables with a row for each sub-part. There are hundreds of parts and each part has up to 10-15 sub-part. I would like to number the rows in each table to use as automatically-generated sub-part numbers. I found several articles on the Internet that suggest using a numbered list. One example is: http://blogs.techrepublic.com.com/msoffice/?p=487 The problem with that approach is I have to manually restart the numbering in each table, such as if I copy a table (as a template) for a new table. Another problem it the tab character that Word inserts after the list number. Is there a way to get each table to automatically restart numebring at "1" (after the header row) and replace the tab character with a single space? If not, is there another way? |
#2
|
|||
|
|||
Simple way to number the rows in a table?
Run a macro containing the following code:
Dim i As Long Dim atable As Table For Each atable In ActiveDocument.Tables With atable For i = 1 To .Rows.Count .Cell(i, 1).Range.Text = i Next i End With Next atable If you want the numbering to start in the second row of each table, use Dim i As Long Dim atable As Table For Each atable In ActiveDocument.Tables With atable For i = 2 To .Rows.Count .Cell(i, 1).Range.Text = i - 1 Next i End With Next atable -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP, originally posted via msnews.microsoft.com "Sesquipedalian Sam" wrote in message ... I have a document containing descriptions of parts. Each part section contains a tables with a row for each sub-part. There are hundreds of parts and each part has up to 10-15 sub-part. I would like to number the rows in each table to use as automatically-generated sub-part numbers. I found several articles on the Internet that suggest using a numbered list. One example is: http://blogs.techrepublic.com.com/msoffice/?p=487 The problem with that approach is I have to manually restart the numbering in each table, such as if I copy a table (as a template) for a new table. Another problem it the tab character that Word inserts after the list number. Is there a way to get each table to automatically restart numebring at "1" (after the header row) and replace the tab character with a single space? If not, is there another way? |
#3
|
|||
|
|||
Simple way to number the rows in a table?
On Sat, 25 Jul 2009 16:28:45 +1000, "Doug Robbins - Word MVP"
wrote: Run a macro containing the following code: Dim i As Long Dim atable As Table For Each atable In ActiveDocument.Tables With atable For i = 1 To .Rows.Count .Cell(i, 1).Range.Text = i Next i End With Next atable If you want the numbering to start in the second row of each table, use Dim i As Long Dim atable As Table For Each atable In ActiveDocument.Tables With atable For i = 2 To .Rows.Count .Cell(i, 1).Range.Text = i - 1 Next i End With Next atable Thank you. |
Thread Tools | |
Display Modes | |
|
|