Class ModelTableColumn (Excel VBA)

The class ModelTableColumn represents a single column inside a ModelTable object.


To use a ModelTableColumn class variable it first needs to be instantiated, for example

Dim mtc as ModelTableColumn
Set mtc = ActiveWorkbook.Model.ModelRelationships(1).ForeignKeyColumn

The following procedures can be used to set variables of type ModelTableColumn: ModelRelationship.ForeignKeyColumn, ModelRelationship.PrimaryKeyColumn and ModelTableColumns.Item.

For Each

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

Dim mtc As ModelTableColumn
For Each mtc In ActiveWorkbook.Model.ModelRelationships.ModelTableColumns
Next mtc


Returns the XlParameterDataType enumeration of the ModelTableColumn.

Dim lngDataType As Long
lngDataType = ActiveWorkbook.Model.ModelRelationships(1).ForeignKeyColumn.DataType


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

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


Returns a Long value that represents the number of ModelTableColumn objects in a ModelTableColumns object.

Dim lngCount As Long
lngCount = ActiveWorkbook.Model.ModelTables(1).ModelTableColumns.Count


Returns a ModelTableColumn object from the ModelTableColumns collection.

Item (Index)

Index: The index number for the object.

Dim mtc As ModelTableColumn
Set mtc = ActiveWorkbook.Model.ModelTables(1).ModelTableColumns(Index:=1)