Excel has a functionality to trace the precedents
and dependents
of a cell (via menu Tools > Auditing
). For instance, if we have = C3 + 1
in C4
, then Excel can trace that C4
is a dependent of C3
(C3
is a precedent of C4
).
As VBA code also has impact to Excel cells, I would like to know if there is any tool to trace the dependency between VBA code and Excel cells.
For example, if there is a line of VBA code Range("C4").Value = Range("C3").Value + 1
, is there a tool to trace that C4
might be a dependent of C3
?
Also, if there is a line of VBA code Range("C4").Value = 5
, is there a tool to trace that C4
might be modified by this piece of code?
Changes made by VBA cannot be tracked easily (because cells may be modified in arbitrary way by a function or passed to a function as string).
There is something you can do but it's a little bit tricky and I guess it won't really satisfy you: you can detect if a cell has any dependency.
How it works? Write a macro like this:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
End Sub
You may log to the immediate window the changed cells. Now change a cell value, in the immediate window you'll see all cells that depend on the cell you changed. Disadvantages?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With