Class ModelTableColumn (Excel VBA)

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

Item

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

DataType

Returns the XlParameterDataType enumeration of the ModelTableColumn.

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

Name

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

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

ModelTableColumns.Count

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

ModelTableColumns.Item

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)