Freigeben über


NamedRange.Dependents Property

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

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

Syntax

'Declaration
ReadOnly Property Dependents As Range
Range Dependents { get; }

Property Value

Type: Microsoft.Office.Interop.Excel.Range
A Microsoft.Office.Interop.Excel.Range that represents the range containing all the dependents of the NamedRange control.

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.

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.

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
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();
}

.NET Framework Security

See Also

Reference

NamedRange Interface

Microsoft.Office.Tools.Excel Namespace