DirectPrecedents Property
TOC
Collapse the table of content
Expand the table of content

NamedRange.DirectPrecedents Property

 

Gets a Microsoft.Office.Interop.Excel.Range that represents the range containing all the direct precedents of the NamedRange control.

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

Range DirectPrecedents { get; }

Property Value

Type: Microsoft.Office.Interop.Excel.Range

A Microsoft.Office.Interop.Excel.Range that represents the range containing all the direct precedents of the NamedRange control.

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.

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();
}
Return to top
Show:
© 2016 Microsoft