Class ModelTable (Excel VBA)

The class ModelTable represents a table in the data model. To use a ModelTable class variable it first needs to be instantiated, for example


Dim mdlt as ModelTable
Set mdlt = ActiveWorkbook.Model.ModelTables(Index:=1)

For Each

Here is an example of processing the ModelTable items in a collection.


Dim mdlt As ModelTable
For Each mdlt In ActiveWorkbook.Model.ModelTables
	
Next mdlt

ModelTableColumns

Collection of ModelTableColumns objects that make up the ModelTable.


Dim mtcsModelTableColumns As ModelTableColumns
Set mtcsModelTableColumns = ActiveWorkbook.Model.ModelTables(1).ModelTableColumns

Name

Returns a String value that represents the name of the object.


Dim strName As String
strName = ActiveWorkbook.Model.ModelTables(1).Name

RecordCount

Returns the total row count for the model table.


Dim lngRecordCount As Long
lngRecordCount = ActiveWorkbook.Model.ModelTables(1).RecordCount

Refresh

Refreshes the model table source connections.


ActiveWorkbook.Model.ModelTables(1).Refresh

SourceName

Name of the data source for the table. If the table has no data source, the call will generate a run-time error.


Dim strSourceName As String
strSourceName = ActiveWorkbook.Model.ModelTables(1).SourceName

SourceWorkbookConnection

Returns the Workbook Connection from which the model table originated.


Dim wbconSourceWorkbookConnection As WorkbookConnection
Set wbconSourceWorkbookConnection = ActiveWorkbook.Model.ModelTables(1).SourceWorkbookConnection