NativeExcel for .Net Developer's Reference

IRange.Count Property

Returns the number of cells in the range.

[Visual Basic]
PropertyReadOnlyCountAsInteger
[C#]
intCount{get;}
[C++]
__propertyintget_Count();
[JScript]
functiongetCount():int

Example

This example displays the number of cells in the selection on sheet one.

[C#]
 IWorksheet sheet = book.Worksheets[1];
 MessageBox.Show(String.Format("The selection contains {0} cells", sheet.Selection.Count));
[VisualBasic]
 Dim sheet As IWorksheet = book.Worksheets(1)
 MessageBox.Show(String.Format("The selection contains {0} cells", sheet.Selection.Count))
[C++]
 IWorksheet* sheet = book->Worksheets->Item[1];
 MessageBox::Show(String::Format(S"The selection contains {0} cells", sheet->Selection->Count));

See Also

IRange Interface | NativeExcel Namespace | Selection Property