Using Debug.Print for debugging now becomes even simpler
Debug.Print writes its output to the Immediate Window and is much used to debug code
- just plant several such statements in the macro that is giving difficulties and you can see which branches were passed and
what the values of variables at each point are. E.g. in below code...
If Len(Module) > 0 Then MessageLong = MessageLong & " " & Module
If Len(Procedure) > 0 Then MessageLong = MessageLong & " " & Procedure
If ErrLine > 0 Then MessageLong = MessageLong & " line " & ErrLine
... when entering ? in a new line below the code Debug.Print gets inserted and a menu opens
allowing you to select whatever info you want to be printed.
Immediate Window can be opened by pressing Ctrl-G or from the menu View » Immediate