Range プロパティ (Excel)Range.Count property (Excel)
コレクションに含まれるオブジェクトの数を表す長整数型 (Long) の値を返します。Returns a Long value that represents the number of objects in the collection.
構文Syntax
式。Countexpression.Count
expression は Range オブジェクトを表す変数です。expression A variable that represents a Range object.
注釈Remarks
Countプロパティは**countlarge** プロパティと同じですが、指定した範囲に2147483647を超えるセルがある場合 (2048 列未満)、 countプロパティでオーバーフローエラーが発生する点が異なります。The Count property is functionally the same as the CountLarge property, except that the Count property will generate an overflow error if the specified range has more than 2,147,483,647 cells (one less than 2,048 columns). ただし、 Countlargeプロパティは、ワークシートの最大サイズ (17179869184 セル) までの範囲を処理できます。The CountLarge property, however, can handle ranges up to the maximum size for a worksheet, which is 17,179,869,184 cells.
例Example
次の使用例は、シート 1 で選択されているセル範囲の列数を表示します。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
サポートとフィードバックSupport and feedback
Office VBA またはこの説明書に関するご質問やフィードバックがありますか?Have questions or feedback about Office VBA or this documentation? サポートの受け方およびフィードバックをお寄せいただく方法のガイダンスについては、Office VBA のサポートおよびフィードバックを参照してください。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.