Insert Word Table Rows Below the Cursor with VBA
Question details
Modify a Word VBA macro to insert a table row below the row containing the cursor.

- Product
- Microsoft Word
- Device & OS
- not provided
- Scenario
- A user is editing a Word table and wants a macro to add a row below the current cursor position.
- Observed behavior
- The macro should insert a new row below the current row, including when the cursor is in the last row.
Open the document in Microsoft Word and place the cursor inside the table row where you want to insert a row below. Make sure you can access the VBA editor and that macros are permitted for the document.
Update the Word VBA macro to insert below the current row
Use the next row as the insertion reference, or append a row when the cursor is in the last row.
In Word, open the VBA editor with Alt+F11, then open the module containing your table-row macro.
Replace the relevant insertion logic with this example: Sub InsertRowBelowCursor() Dim oTbl As Table Dim lngPosit As Long If Not Selection.Information(wdWithInTable) Then MsgBox "Place the cursor inside a table first." Exit Sub End If Set oTbl = Selection.Tables(1) lngPosit = Selection.Rows(1).Index If lngPosit < oTbl.Rows.Count Then oTbl.Rows.Add BeforeRow:=oTbl.Rows(lngPosit + 1) Else oTbl.Rows.Add End If End Sub
Return to the document, click inside a table row, and run InsertRowBelowCursor from the Macros dialog. Test both a middle row and the last row.
Edit Word tables with WPS Writer
WPS Office is a free, lightweight alternative with a familiar interface for editing documents and tables. Its Word format compatibility makes moving documents from Microsoft Office straightforward, although it does not fix Microsoft Word VBA errors.

Frequently Asked Questions
Why does the macro use the next row as a reference?
Word's Rows.Add method inserts before the specified BeforeRow. Referencing oTbl.Rows(lngPosit + 1) therefore places the new row below the current row.
How do I insert below the last row?
When the current row is the last row, call oTbl.Rows.Add without a BeforeRow argument. This appends a row to the table.
What should I check if I get runtime error 5941?
Click inside the intended table before running the macro and check that the requested table or row exists. In particular, don't reference lngPosit + 1 when the current row is the last row.
Can I add a row without using a macro?
In Word, click inside the table row, then use the table layout tools and select Insert Below.




