NamedRange.Dependents 属性


获取一个 Range,它表示包含 NamedRange 控件的所有依赖单元格的范围。Gets a Range that represents the range containing all the dependents of the NamedRange control.

public Microsoft.Office.Interop.Excel.Range Dependents { get; }



一个 Range,表示包含 NamedRange 控件的所有依赖单元格的范围。A Range that represents the range containing all the dependents of the NamedRange control.


下面的代码示例创建一个 NamedRange ,并将单元格 A1 中的引用设置为引用 NamedRangeThe following code example creates a NamedRange and sets a reference in cell A1 to refer to the NamedRange. 然后,它将 A2 单元格中的引用设置为引用单元格 A1。It then sets a reference in cell A2 to refer to cell A1. 然后,该代码示例使用 Dependents 属性来选择的依赖项 NamedRange ,即单元格 A1 和 A2。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";
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"
End Sub


如果存在多个依赖项,则此属性可以返回多重选择(对象的联合 Microsoft.Office.Interop.Excel.Range )。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.