PDA

View Full Version : Add row to table refering to a Cell Value



Ollihoup
04-28-2017, 03:12 AM
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!!

mana
04-28-2017, 05:00 AM
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