Consulting

Results 1 to 2 of 2

Thread: Add row to table refering to a Cell Value

  1. #1

    Add row to table refering to a Cell Value

    Hi All

    Can you please help me with a code, in VBA, that adds n number of rows to a table, where n is referring to a cell value?

    Thanks!!

  2. #2
    VBAX Expert
    Joined
    Sep 2016
    Posts
    788
    Location
    Option Explicit
    
    Sub test()
        Dim tbl As ListObject
        Dim n As Long
        Dim i As Long
        
        Set tbl = Activesheet.ListObjects(1)
        n = Range("a1").Value
          
        For i = 1 To n
            tbl.ListRows.Add
        Next
        
    End Sub

Posting Permissions

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