Compartir a través de


NamedRange.Dependents Property

Definition

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

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

Property Value

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

Examples

The following code example creates a NamedRange and sets a reference in cell A1 to refer to the NamedRange. It then sets a reference in cell A2 to refer to cell A1. The code example then uses the Dependents property to select the dependents of the NamedRange, which are cells A1 and A2.

This example is for a document-level customization.

Microsoft.Office.Tools.Excel.NamedRange dependentsRange;
private void SelectDependents()
{
    dependentsRange = this.Controls.AddNamedRange(
        this.Range["B1"], "createMonthRange");
    this.dependentsRange.Value2 = "Smith";
    this.Range["A1"].Value2 = "=" +
        this.dependentsRange.Address[false, true,
        Excel.XlReferenceStyle.xlA1, false];

    this.Range["A2"].Value2 = "=A1";
    this.dependentsRange.Dependents.Select();
}
Private dependentsRange As Microsoft.Office.Tools.Excel.NamedRange

Private Sub SelectDependents()
    dependentsRange = Me.Controls.AddNamedRange( _
        Me.Range("B1"), "createMonthRange")
    Me.dependentsRange.Value2 = "Smith"
    Me.Range("A1").Value2 = "=" & _
        Me.dependentsRange.Address(False, True, _
        Excel.XlReferenceStyle.xlA1, False, )

    Me.Range("A2").Value2 = "=A1"
    Me.dependentsRange.Dependents.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