Megosztás a következőn keresztül:


NamedRange.DirectPrecedents Property (2007 System)

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

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

Syntax

'Declaration
<BrowsableAttribute(False)> _
Public ReadOnly Property DirectPrecedents As Range
'Usage
Dim instance As NamedRange 
Dim value As Range 

value = instance.DirectPrecedents
[BrowsableAttribute(false)]
public Range DirectPrecedents { get; }
[BrowsableAttribute(false)]
public:
property Range^ DirectPrecedents {
    Range^ get ();
}
public function get DirectPrecedents () : Range

Property Value

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

Remarks

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

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

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.

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
Microsoft.Office.Tools.Excel.NamedRange precedentRange;
private void SelectDirectPrecedents()
{
    precedentRange = this.Controls.AddNamedRange(
        this.Range["B1", missing], "precedentRange");

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

    this.precedentRange.Value2 = "=C2";
    this.precedentRange.DirectPrecedents.Select();
}

.NET Framework Security

See Also

Reference

NamedRange Class

NamedRange Members

Microsoft.Office.Tools.Excel Namespace