NativeExcel for .Net Developer's Reference

IRange.Count Property

Returns the number of cells in the range.

[Visual Basic]
Property ReadOnly Count As Integer
[C#]
int Count { get; }
[C++]
__property int get_Count();
[JScript]
function get Count() : 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));
[Visual Basic]
 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