Whatever code module that/those procedure(s) are in now is fine, but, you have to be able to run it/them from an Application Event procedure. That means it/they need to be in their own sub(s), or be duplicated in the Application Event Sub.on opening the workbook, code runs that hides the workbook and only shows the userform... - are you referring to it being placed in the userform sub somewhere ??
Always place "Option Explicit" at the top of all your code pages. You should use the VBA Menu >> Tools >> Options >> Editor Tab and check all the boxes in the top Frame. This will auto place "Option Explicit" in new code pages and enable other code checking tools in VBA.
To get help on any VBA term, place the cursor in or next to the word and press F1. Pressing F2 will bring up an interesting page that gives you a lot of information about VBA terms.
I am 69+yo and still use Excel XP, depending on your system you may have to modify the code to work on your system.
You might even have to go to Microsoft.com for help. DuckDuckgo is your friend. Search the internet for "Excel VBA " + the VBA term. "Excel VBA Application Event"
Good tutorial here. Detailed tutorial here. MS Excel online help here.





Reply With Quote