Are you looking for a way to track a specific cell, or for a way to track all cells affected by VBA code? Also, "affected" as in "value was changed" or "formula was changed", or "cell was merged with another", "range was unmerged", or "borders were changed", or "backcolor was changed"? Is adding conditional formatting "affecting" a cell? Data validation?
And then, there are more ways a cell can be "affected", too. Without tracking the code as it's running, it could be hard to tell whether this myRange
variable is affecting the cell you're looking for.. especially if methods like Range.Offset
and Range.Resize
are used.
Then ranges can be named, so Range("Foo")
might be referring to a cell you're interested in, but you can't know that without verifying whether Names("Foo").RefersToRange
includes that cell.
Short of carefully reviewing the code, I'm afraid you can't.
If no macro is highlighting any cell in bright yellow, you could always make a copy of the file and then handle Workbook_SheetChange
in ThisWorkbook
:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Target.Interior.Color = vbYellow
End Sub
You can easily add conditional logic here to only recolor modified cells from a specific sheet, or from a specific column or row.
Now remove or comment-out any Application.EnableEvents
toggling everywhere in the code, and run your macros - the cells it affected (assuming a change in value is what we're after) should all be bright yellow.
If you need to know what code caused this, you can place a breakpoint there, and inspect the call stack:
.Dirty
Designates a range to be recalculated when the next recalculation occurs. How does this tell you which cells are affected by a macro? – PᴇʜDirty
to mean that the cell has changed value :o) – Paul