A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Word » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Simple way to number the rows in a table?



 
 
Thread Tools Display Modes
  #1  
Old July 25th, 2009, 12:07 AM posted to microsoft.public.word.newusers
Sesquipedalian Sam
external usenet poster
 
Posts: 131
Default 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  
Old July 25th, 2009, 07:28 AM posted to microsoft.public.word.newusers
Doug Robbins - Word MVP
external usenet poster
 
Posts: 8,239
Default 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  
Old July 25th, 2009, 10:47 AM posted to microsoft.public.word.newusers
Sesquipedalian Sam
external usenet poster
 
Posts: 131
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 01:16 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.