Excel, VBA, Table

TU: http://www.thespreadsheetguru.com/blog/2014/6/20/the-vba-guide-to-listobject-excel-tables

A oprócz tego taki kod w VBA, żeby okreslić nazwę tabeli w której mamy zaznaczoną komórkę:

Sub DetermineActiveTable()
Dim SelectedCell As Range
Dim TableName As String
Dim ActiveTable As ListObject
Set SelectedCell = ActiveCell
‘Determine if ActiveCell is inside a Table
On Error GoTo NoTableSelected
TableName = SelectedCell.ListObject.Name
Set ActiveTable = ActiveSheet.ListObjects(TableName)
On Error GoTo 0
‘Do something with your table variable (ie Add a row to the bottom of the ActiveTable)
ActiveTable.ListRows.Add AlwaysInsert:=True
Exit Sub
‘Error Handling
MsgBox “There is no Table currently selected!”, vbCritical
End Sub