Index Property

Microsoft Excel Visual Basic

Returns the index number of the ListColumn object within the ListColumns collection. Read-only Integer.

expression.Index

expression    Required. An expression that returns ListColumn object.

ShowIndex property as it applies to the ListRow object.

For the ListRow object, returns or sets the index number of the object within the ListRows collection. Read-only Long.

expression.Index

expression    Required. An expression that returns ListRow object.

ShowIndex property as it applies to the PivotFormula object.

For the PivotFormula object, returns or sets the index number of the object within the PivotFormulas collection. Read/write Long.

expression.Index

expression    Required. An expression that returns one of the above objects.

ShowIndex property as it applies to all other objects in the Applies To list.

Returns the index number of the object within the collection of similar objects. Read-only Long.

expression.Index

expression    Required. An expression that returns one of the above objects.

For information about using the Index worksheet function in Visual Basic, see Using Worksheet Functions in Visual Basic.

Example

This example displays the tab number of the sheet specified by the name that you type. For example, if Sheet4 is the third tab in the active workbook, the example displays "3" in a message box.

Sub DisplayTabNumber()
    Dim strSheetName as String

    strSheetName = InputBox("Type a sheet name, such as Sheet4.")

    MsgBox "This sheet is tab number " & Sheets(strSheetName).Index
End Sub