NamedRange.End 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 cell at the end of the region that contains the NamedRange control.
public:
property Microsoft::Office::Tools::Excel::NamedRange_EndType ^ End { Microsoft::Office::Tools::Excel::NamedRange_EndType ^ get(); };
public Microsoft.Office.Tools.Excel.NamedRange_EndType End { get; }
member this.End : Microsoft.Office.Tools.Excel.NamedRange_EndType
Public ReadOnly Property End As NamedRange_EndType
Property Value
A Range that represents the cell at the end of the region that contains the NamedRange control.
Examples
The following code example creates a NamedRange and then populates a cell to the right to create a boundary for the region of blank columns. It then displays a message box asking if you want to select the end of the region to the right of the NamedRange.
This version is for a document-level customization.
Microsoft.Office.Tools.Excel.NamedRange endRange;
private void SelectEnd()
{
endRange = this.Controls.AddNamedRange(
this.Range["B1", "D4"], "endRange");
this.Range["H1"].Value2 = 123;
endRange.Select();
if (MessageBox.Show("Select end of region to the right?",
"End of Region Test", MessageBoxButtons.OKCancel) == DialogResult.OK)
{
this.endRange.End[Excel.XlDirection.xlToRight].Select();
}
}
Private endRange As Microsoft.Office.Tools.Excel.NamedRange
Private Sub SelectEnd()
endRange = Me.Controls.AddNamedRange( _
Me.Range("B1", "D4"), "endRange")
Me.Range("H1").Value2 = 123
endRange.Select()
If MessageBox.Show("Select end of region to the right?", _
"End of Region Test", MessageBoxButtons.OKCancel) = _
DialogResult.OK Then
Me.endRange.End(Excel.XlDirection.xlToRight).Select()
End If
End Sub
This version is for an application-level add-in.
Remarks
The End property is intended to be used with the following parameter.
Parameter | Description |
---|---|
Direction |
One of the XlDirection values that indicates the direction in which to find the last cell. |
If you attempt to use End without specifying any parameters, End will get a NamedRange_EndType object that is part of the Visual Studio infrastructure and is not intended to be used directly from your code.
This property is equivalent to pressing END+UP ARROW, END+DOWN ARROW, END+LEFT ARROW, or END+RIGHT ARROW.