'Create Dynamic Table in Excel VBA
Sub VBAF1_Create_Dynamic_Table()
'Variable Declaration
Dim tableListObj As ListObject
Dim TblRng As Range
'Sheet Name
With ActiveSheet
'Find Last Row
lLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
'Find Last Column
lLastColumn = 1
'Range to create table
Set TblRng = .Range("A1", .Cells(lLastRow, lLastColumn))
'Create table in above specified range
Set tableListObj = .ListObjects.Add(xlSrcRange, TblRng, , xlYes)
'Specifying table name
tableListObj.Name = "FirstDynamicTable"
'Specify table style
tableListObj.TableStyle = "TableStyleMedium14"
End With
'Display message on the screen
' MsgBox "Table has created successfully.", vbInformation, "VBAF1"
End Sub