Sorry I guess I was a little too obtuse. I have the variable declared as a public variable, but how do I define or set the variable value so every routine can use the workbook name value regardless of the order the routines are executed. i.e., without redefining the variable every time I launch any routine, in any order.
I have one main routine that calls several other subroutines and it passes the workbook name variable to each of the subroutines it calls, and that works fine. But each of the subroutines can be called individually outside of the main routine. In order to do that I have to redefine the work name variable in each subroutine, and that works for executing each subroutine individually. But once I relaunch the main routine, the subroutines lose the value of the variable as it is being passed to them; i.e., the variable name is being redefined within each subroutine. And somewhere along the line the value gets set to null.
The subroutines open other workbooks and copy data into the main workbook in a separate sheet for each separate data file workbook. The subroutines need to be able to activate the main workbook to continue execution which includes arranging, sorting, subtotaling, and formatting the data, then closing the data file workbook(s).
All routines are in the same module. I'm using the following code
Public myWbk As String 'in the Declarations section of Module1
myWbk = ActiveWorkbook.Name 'in each routine
Workbooks(myWbk).Activate 'in each subroutine to get back to the main workbook after opening a data file workbook
I'm certain I'm just doing something out of order and/or in the wrong location(s).