Share via


Count Property

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.  

Count property as it applies to the Adjustments, CanvasShapes, DiagramNodeChildren, DiagramNodes, and ShapeNodes objects.

Returns the number of objects in the collection. Read-only Integer.

expression.Count

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

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

Returns the number of objects in the collection. Read-only Long.

expression.Count

expression   Required. An expression that returns one of the objects in the Applies To list.

Example

This example displays the number of columns in the selection on Sheet1. The code also tests for a multiple-area selection; if one exists, the code loops on the areas of the multiple-area selection.

  Worksheets("Sheet1").Activate
areaCount = Selection.Areas.Count
If areaCount <= 1 Then
    MsgBox "The selection contains " & _
        Selection.Columns.Count & " columns."
Else
    For i = 1 To areaCount
        MsgBox "Area " & i & " of the selection contains " & _
            Selection.Areas(i).Columns.Count & " columns."
    Next i
End If

This example makes the last character in cell A1 a superscript character.

  n = Worksheets("Sheet1").Range("A1").Characters.Count
Worksheets("Sheet1").Range("A1").Characters(n, 1) _
    .Font.Superscript = True