Usually_Wrong
New Member
- Joined
- Oct 6, 2021
- Messages
- 4
- Office Version
- 365
- Platform
- Windows
- Web
Greetings,
I have a table ("Position") that resides within a named range ("Test"). Currently, the named range is for A1:G9, or the green border surrounding the table.
I have the code that inserts a row to the table; however, my issue is that this doesn't make the named range dynamic. I am hoping to modify this code to not insert on row 9 (bottom of the table), but above row 8 instead so the named range expands with the row insertions.
Any help is appreciated. Thank you!
I have a table ("Position") that resides within a named range ("Test"). Currently, the named range is for A1:G9, or the green border surrounding the table.
I have the code that inserts a row to the table; however, my issue is that this doesn't make the named range dynamic. I am hoping to modify this code to not insert on row 9 (bottom of the table), but above row 8 instead so the named range expands with the row insertions.
VBA Code:
Sub InserttoTable()
Dim oSheetName As Worksheet
Dim sTableName As String
Dim loTable As ListObject
sTableName = "Position"
Set oSheetName = Sheets("Sheet1")
Set loTable = oSheetName.ListObjects(sTableName)
loTable.ListRows.Add
End Sub
Any help is appreciated. Thank you!