次の方法で共有


NamedRange.DirectPrecedents Property

Definition

Gets a Range that represents the range containing all the direct precedents of the NamedRange control.

public:
 property Microsoft::Office::Interop::Excel::Range ^ DirectPrecedents { Microsoft::Office::Interop::Excel::Range ^ get(); };
public Microsoft.Office.Interop.Excel.Range DirectPrecedents { get; }
member this.DirectPrecedents : Microsoft.Office.Interop.Excel.Range
Public ReadOnly Property DirectPrecedents As Range

Property Value

A Range that represents the range containing all the direct precedents of the NamedRange control.

Examples

The following code example creates a NamedRange and sets a reference in cell C2 to refer to cell C1, and then sets a reference in the NamedRange to refer to cell C2. The code example then uses the DirectPrecedents property to select the direct precedent of the NamedRange, which is cell C2.

This example is for a document-level customization.

Microsoft.Office.Tools.Excel.NamedRange precedentRange;
private void SelectDirectPrecedents()
{
    precedentRange = this.Controls.AddNamedRange(
        this.Range["B1"], "precedentRange");

    this.Range["C1"].Value2 = 1710;
    this.Range["C2"].Value2 = "=C1";

    this.precedentRange.Value2 = "=C2";
    this.precedentRange.DirectPrecedents.Select();
}
Private precedentRange As Microsoft.Office.Tools.Excel.NamedRange

Private Sub SelectDirectPrecedents()
    precedentRange = Me.Controls.AddNamedRange( _
        Me.Range("B1"), "precedentRange")

    Me.Range("C1").Value2 = 1710
    Me.Range("C2").Value2 = "=C1"

    Me.precedentRange.Value2 = "=C2"
    Me.precedentRange.DirectPrecedents.Select()
End Sub

Remarks

This property can return a multiple selection (a union of Microsoft.Office.Interop.Excel.Range objects) if there is more than one dependent.

This property only works on the active sheet and cannot trace remote references.

Applies to