View Single Post
  #5   Report Post  
Posted to microsoft.public.word.tables
Josh W Josh W is offline
external usenet poster
 
Posts: 44
Default How to insert multiple rows in tables

Thanks Cindy.

"Cindy M -WordMVP-" wrote:

Hi ?B?Sm9zaCBX?=,

does anyone know how to insert a few rows at once in a table? The
options I currently have in the table menu "insert" is only one row at a
time. Lets say I need to add 20 rows at once, how do I do this?

Word will insert as many rows as you have selected when you use the Insert
command. So you can select 20 rows, then use Insert Rows and Word will
insert another 20.

There's no way to specify n number of rows except when initially creating
the table. Although it would certainly be possible to speed things up a bit
using a macro. For example:

Sub Insert_n_Rows()
Dim tbl As Word.Table
Dim doc As Word.Document
Dim strRows As String
Dim nrRows As Long
Dim counter As Long

On Error GoTo ErrHandler
If Selection.Range.Information(wdWithInTable) Then
Set tbl = Selection.Tables(1)
strRows = InputBox("Enter number of rows to insert")
If IsNumeric(strRows) Then nrRows = CLng(strRows)
For counter = 1 To nrRows
tbl.Rows.Add (Selection.Rows(1))
Next
End If

Exit Sub

ErrHandler:
Select Case Err.Number
Case Else
MsgBox Err.Description & vbCr & Err.Number
End Select
End Sub


Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)