Skip to content

Instantly share code, notes, and snippets.

@jfthuong
Last active April 21, 2021 05:44
Show Gist options
  • Save jfthuong/1767571 to your computer and use it in GitHub Desktop.
Save jfthuong/1767571 to your computer and use it in GitHub Desktop.
Insert a given number of rows in a MS Word Table (VBA)
Sub Insert_x_rows()
'
' Insert a given number of rows into a MS Word Table
'
'
Dim n_rows As Integer
n_rows = InputBox("How many rows shall be inserted?", "Insert Rows")
Selection.InsertRowsBelow n_rows
End Sub
@jfthuong
Copy link
Author

Thanks for the comments and suggestions @aamailhot.

The code I wrote was loaded in my default template of MS Word and linked to a button to create rows (hence the InputBox and selection).
Indeed, for a fully automatized workflow, you would need:

  • the location of the table
  • where to add in the table
  • how many rows to add

Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment