![]()
Sub InsertTableRows(ByRef oTable As ListObject, lRowsToInsert As Long) Dim oTableWs As Worksheet Dim lRefRow As Long Set oTableWs = oTable.Parent oTableWs.Activate With oTable If .DataBodyRange Is Nothing Then 'If Table has no Rows lRefRow = .HeaderRowRange.Row 'Use the header row as reference range 'and add a one-row offset to insert -below- header 'Insert blank rows below table header Rows(lRefRow + 1 & ":" & lRefRow + lRowsToInsert).Insert _ Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove Else lRefRow = .DataBodyRange.Rows(1).Row 'Else use the DataBody top-row as reference range 'Insert blank rows below table header Rows(lRefRow & ":" & lRefRow + lRowsToInsert - 1).Insert _ Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove End If End With End Sub
Bookmarks