The results of the debug.prints in the Immediate window are:
Activeworkbook name is: Book1
First-FocusSheet.CodeName =
Match-FocusSheet.CodeName =Sheet1
Match-CodeName =Sheet1
Match-GetWorksheetFromCodeName = Sheet1
When I open a fresh instance of excel and launch this code outside
of the VBE, and Stop it at the bold stop, I notice that the
FocusSheet.CodeName
is not populated before stopping the code, but right after stopping the
code, I can let the macro play or step through it, and the very next
debug.print picks up the
FocusSheet.CodeName, eventhough the only
codes in between are debug.prints and stop. The only difference is that I
have activated the VBE window by making it stop there and somehow, it
is able to understand how to work from the PERSONAL.XLSB and pull
codenames from the ActiveWorkbook and I didn't explicitly name
the Actveworkbook in the code.
WHY? How come it can't work outside of the VBE the first time?
(Incidently, once it runs through the VBE window once, I can now launch it outside of VBE and it will work and on any new workbook I open, as long as I don't close Excel and start over again, then it breaks like it does, until I go into the VBE window again. IF the values I need are not captured before I enter the VBE window, then the code won't work, I have to get into it before the ciritical moment when it captures the codename,l in this case).