# Class ModelMeasure (Excel VBA)

The class ModelMeasure represents a single ModelMeasure object in the ModelMeasures collection.

### Item

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

```
Dim mme as ModelMeasure
Set mme = ActiveWorkbook.Model.ModelMeasures(Index:=1)
```

The following procedures can be used to set variables of type ModelMeasure: ModelMeasures.Add and ModelMeasures.Item.

### For Each

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

```
Dim mme As ModelMeasure
For Each mme In ActiveWorkbook.Model.ModelMeasures
Next mme
```

## AssociatedTable

```
ActiveWorkbook.Model.ModelMeasures(1).AssociatedTable =
```

## Delete

Deletes the model measure from the data model.

```
ActiveWorkbook.Model.ModelMeasures(1).Delete
```

## Description

The description of the model measure.

```
ActiveWorkbook.Model.ModelMeasures(1).Description =
```

## FormatInformation

The format of the model measure.

The formatting of the model measure can be of type:

```
ActiveWorkbook.Model.ModelMeasures(1).FormatInformation =
```

## Formula

The Data Analysis Expressions (DAX) formula of the model measure.

```
ActiveWorkbook.Model.ModelMeasures(1).Formula =
```

## Name

The name of the model measure.

```
ActiveWorkbook.Model.ModelMeasures(1).Name =
```

## ModelMeasures.Add

Adds a model measure to the model.

The formatting of the model measure can be of type:

**Add** (MeasureName, AssociatedTable, Formula, FormatInformation, Description)

```
Dim strMeasureName As String: strMeasureName =
Dim strFormula As String: strFormula =
Dim mme As ModelMeasure
Set mme = ActiveWorkbook.Model.ModelMeasures.Add(MeasureName:=strMeasureName, AssociatedTable:=, Formula:=strFormula, FormatInformation:=)
```

### Arguments

The following arguments are required:

MeasureName (String) - The name of the model measure.

AssociatedTable (ModelTable) - The model table associated with the model measure. This is the table that contains the model measure, as seen in the Field List task pane.

Formula (String) - The Data Analysis Expressions (DAX) formula, inserted as a string.

FormatInformation - The formatting of the model measure. See Remarks

## ModelMeasures.Count

Returns an integer that represents the number of objects in the collection.

```
Dim lngCount As Long
lngCount = ActiveWorkbook.Model.ModelMeasures.Count
```

## ModelMeasures.Item

Returns a single object from a collection.

**Item** (Index)

Index: The name or index number of the object.

```
Dim mme As ModelMeasure
Set mme = ActiveWorkbook.Model.ModelMeasures(Index:=1)
```