Expand Minimize

NamedRange.CurrentRegion Property

Gets a Microsoft.Office.Interop.Excel.Range that represents the current region.

Namespace:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel (in Microsoft.Office.Tools.Excel.dll)

Range CurrentRegion { get; }

Property Value

Type: Microsoft.Office.Interop.Excel.Range
A Microsoft.Office.Interop.Excel.Range that represents the current region.

The current region is a range bounded by any combination of blank rows and blank columns.

This property cannot be used on a protected worksheet.

The following code example creates a NamedRange and populates it with the value 123. It then colors the current region, which is the region bounded by blank rows and columns, green.

This example is for a document-level customization.

Microsoft.Office.Tools.Excel.NamedRange currentRegionRange;
private void ColorCurrentRegion()
{
    currentRegionRange = this.Controls.AddNamedRange(
        this.Range["C3", "E5"], "currentRegionRange");
    currentRegionRange.Value2 = "123";

    // Set the color of the region to the RGB value for green. 
    this.currentRegionRange.CurrentRegion.Interior.Color = 0xFF00;
} 

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft