I am trying to store the variables and actions in VBA macro for troubleshooting or debugging purposes like below. Is there any built-in method to do this in background for this instead using "If DEBUG_MODE Then" for every line I need to store?
Dim DEBUG_MODE As Boolean
Sub PopulateData()
Dim ws As Worksheet, cel As Range
DEBUG_MODE = True
For Each ws In ActiveWorkbook.Worksheets
If DEBUG_MODE Then PrintToFile ws.Name & "," & Now
For Each cel In ws.Range("A1:A1000")
If cel.Value = cel.Offset(0, 1).Value Then
If DEBUG_MODE Then PrintToFile "Value Matched at " & cel.Address
cel.Offset(0, 2).Value = cel.Offset(0, 2).Value * 5
End If
Next cel
Next ws
End Sub