Results 1 to 4 of 4

Insert Multiple Blank Rows to a ListObject Table

Threaded View

Dominicus Insert Multiple Blank Rows to... 06-19-2012, 07:37 PM
arlu1201 Re: Insert Multiple Blank... 06-20-2012, 03:30 AM
Dominicus Re: Insert Multiple Blank... 06-20-2012, 03:53 AM
arlu1201 Re: Insert Multiple Blank... 06-20-2012, 04:14 AM
  1. #1
    Registered User
    Join Date
    06-10-2012
    Location
    Bay Area, California
    MS-Off Ver
    Excel 2016
    Posts
    28

    Insert Multiple Blank Rows to a ListObject Table

    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
    Last edited by Dominicus; 06-20-2012 at 03:52 AM. Reason: corrected

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1