I created a universal userform on which the user would select a building location from a combobox. This is tied to a sheet with the same name as the location. I am looking to have it so that when they hit the enter button, the data on the form will be entered in a table on the corresponding page. Because Tables have to have a unique name that is not repeated across any sheets, I am struggling with how to set the table range using a string. I named all tables with the following format: TableSheetname. Is there a way to set a string equal to "Table" & Sheetname?
Dim oNewRow As ListRow, rng As Range, tbl As String
Set tbl = "Table" & sht
Set rng = Worksheets(sht).Range(tbl)
rng.Select
Set oNewRow = Selection.ListObject.ListRows.Add(AlwaysInsert:=True)
With ws
oNewRow.Range.Cells(1, 1).Value = Me.box1.Value
oNewRow.Range.Cells(1, 2).Value = Me.box2.Value
oNewRow.Range.Cells(1, 3).Value = Me.box3.Value
oNewRow.Range.Cells(1, 4).Value = Me.box4.Value
oNewRow.Range.Cells(1, 5).Value = Me.box5.Value
oNewRow.Range.Cells(1, 6).Value = Me.box6.Value
End With