NamedRange.CurrentRegion Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets a Range that represents the current region.
public:
property Microsoft::Office::Interop::Excel::Range ^ CurrentRegion { Microsoft::Office::Interop::Excel::Range ^ get(); };
public Microsoft.Office.Interop.Excel.Range CurrentRegion { get; }
member this.CurrentRegion : Microsoft.Office.Interop.Excel.Range
Public ReadOnly Property CurrentRegion As Range
Property Value
A Range that represents the current region.
Examples
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;
}
Private currentRegionRange As Microsoft.Office.Tools.Excel.NamedRange
Private Sub ColorCurrentRegion()
currentRegionRange = Me.Controls.AddNamedRange( _
Me.Range("C3", "E5"), "currentRegionRange")
currentRegionRange.Value2 = "123"
' Set the color of the region to the RGB value for green.
Me.currentRegionRange.CurrentRegion.Interior.Color = &HFF00
End Sub
Remarks
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.