循环通过细胞依赖

时间:2010-10-19 17:19:15

标签: vba

这表达了我想做的事,但显然不起作用。我想我想要做的是明确的:

获取一个单元格,获取其依赖项计数,并输出所有这些。

提前感谢任何输入

            Sub Extract()
            Dim i As Integer

                    For i = 1 To Workbooks("myBook.xls").Worksheets(1).Cells(14, 5).Dependents.Count
                        Debug.Print (Workbooks("myBook.xls").Worksheets(1).Cells(14, 5).Dependents(i))
                    Next i
            End Sub

1 个答案:

答案 0 :(得分:3)

你可以做到

Sub Extract()
Dim i As Range
    With Workbooks("Book1.xls").Worksheets(1).Cells(14, 5)
        For Each i In .Dependents
            Debug.Print i.Value i.Address
    Next i
    End With

End Sub

HTH!

修改

.Dependentstransitive closure os .DirectDependents,我不确定你想要哪一个......试试这两个!