다음을 통해 공유


NamedRange.Item Property

Definition

Gets a Range that represents a range at an offset to the NamedRange control.

public:
 property Microsoft::Office::Tools::Excel::NamedRange_ItemType ^ Item { Microsoft::Office::Tools::Excel::NamedRange_ItemType ^ get(); };
public Microsoft.Office.Tools.Excel.NamedRange_ItemType Item { get; }
member this.Item : Microsoft.Office.Tools.Excel.NamedRange_ItemType
Public ReadOnly Property Item As NamedRange_ItemType

Property Value

A Range that represents a range at an offset to the NamedRange control.

Examples

The following code example creates a NamedRange and then uses the Item property to select the cell that is offset from the NamedRange by three columns and three rows.

This version is for a document-level customization.

Microsoft.Office.Tools.Excel.NamedRange itemRange;
private void SelectItem()
{
    itemRange = this.Controls.AddNamedRange(
        this.Range["A1"], "itemRange");
    itemRange.Value2 = "NamedRange";
    Excel.Range offsetCell =
        (Excel.Range)this.itemRange.Item[3, 3];
    offsetCell.Value2 = "Offset cell.";
    offsetCell.Select();
}
Private itemRange As Microsoft.Office.Tools.Excel.NamedRange

Private Sub SelectItem()
    itemRange = Me.Controls.AddNamedRange( _
        Me.Range("A1"), "itemRange")
    itemRange.Value2 = "NamedRange"
    Dim offsetCell As Excel.Range = _
        CType(Me.itemRange.Item(3, 3), Excel.Range)
    offsetCell.Value2 = "Offset cell."
    offsetCell.Select()
End Sub

This version is for an application-level add-in.

Remarks

The Item property is intended to be used with the following parameters.

Parameter Description
RowIndex The index number of the cell you want to access, in order from left to right. NamedRange.Item(1) returns the upper-left cell in the range; NamedRange.Item(2) returns the cell immediately to the right of the upper-left cell.
ColumnIndex A number or string that indicates the column number of the cell you want to access, starting with either 1 or "A" for the first column in the range.

If you attempt to use Item without specifying any parameters, Item will get a NamedRange_ItemType object that is part of the Visual Studio infrastructure and is not intended to be used directly from your code.

The RowIndex and ColumnIndex arguments are relative offsets. In other words, specifying a RowIndex of 1 returns cells in the first row of the range, not the first row of the worksheet.

Applies to