Show AllShow All

Count Property

ShowCount property as it applies to the Adjustments, CanvasShapes, DiagramNodeChildren, DiagramNodes, ListObjects, ListRows, ListColumns, and ShapeNodes objects.

ShowCount property as it applies to all other 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.

Sub DisplayColumnCount()
    Dim iAreaCount As Integer
    Dim i As Integer

    Worksheets("Sheet1").Activate
    iAreaCount = Selection.Areas.Count

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

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

Sub MakeSuperscript()
    Dim n As Integer

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