Reputation: 1
I have searched alot of sites on the internet, and I'm guessing I haven't found an answer because it is not possible, to try to understand the following:
I would like to understand if a Cell containing a value (say 10) plays into / forms part of a formula further into the document. I KNOW that the cell I have is NOT a formula cell, it is a single entry, however, I am trying to understand if this cell forms part of a formula. The need for this is there are ALOT of formulas and ALOT of data, and I am trying to see which data is relvant and which data is not.
Hope somone can help?
Kind regards
Paul
Upvotes: 0
Views: 261
Reputation: 31364
Manually you can use "Trace Dependents" on the 'Formula Auditing' menu under "Formulas" tool tab.
Using VBA you can check the number of dependents like this:
Range("A1").Dependents.Count
If you want a list of cell addresses that cell A1 is used in you can do this:
MsgBox (Range("A1").Dependents.Address)
I have A1 used in two other cells so my result looks like this:
Full code with error checking:
Sub test()
On Error Resume Next
If Range("A1").Dependents Is Nothing Then
MsgBox ("No dependents found")
Else
MsgBox (Range("A1").Dependents.Address)
End If
End Sub
Upvotes: 2
Reputation: 1561
The Dependents
property of a Range
object gives you the dependent cells of your formula. Be careful you will get an error if there are no dependent cells
Function hasDependents(r As Range) As Boolean
On Error GoTo err
hasDenpedents = r.Dependents
Exit Function
err:
hasDependents = False
End Function
And then
if hasDependents([A1]) then
'...
Upvotes: 1