Export (0) Print
Expand All
Expand Minimize

Worksheet.UsedRange Property

Gets a Microsoft.Office.Interop.Excel.Range object that represents the used range on the worksheet.

Namespace: Microsoft.Office.Tools.Excel
Assembly: Microsoft.Office.Tools.Excel (in microsoft.office.tools.excel.dll)

public virtual Range UsedRange { get; }

Property Value

A Microsoft.Office.Interop.Excel.Range object that represents the used range on the worksheet.

The following code example uses the UsedRange property to select the range of used cells on a worksheet. The example first sets the range of cells from A1 to C3 on the current worksheet to the value 23. If the worksheet is visible, then the example uses the UsedRange property to select the Microsoft.Office.Interop.Excel.Range of used cells.

private void SelectUsedRange()
{
    this.Activate();
    this.Range["A1", "C3"].Value2 = 23;
    if (this.Visible == Excel.XlSheetVisibility.xlSheetVisible)
    {
        this.UsedRange.Select();
    }
}

Show:
© 2014 Microsoft