I need help to display a userform when I open a particular excel sheet.(Meaning when I open the excel sheet, the userform will automatically appear with it).I can't seem to use the userform1.show command. Is there any vb code to do this coz I am using vb to write the code? pls help.thanks
but if the workbook's name is another like "company". Can I change the "workbook" to "company"? And where do I put the code?
If I think I get what you're asking regarding the ThisWorkbook module. That is a static name and will be the same regardless of the workbook's actual name.
Workbook level events go into that module. I.E. Workbook_Open, Workbook_BeforeClose, Workbook_BeforePrint, etc. Event names are always the same (partially to keep you sane), so SmittysNewWorkbook_Open wouldn't do a damn thing, but Workbook_Open within Smitty's New Workbook would.
Worksheet level events go in the specific sheet modules, Worksheet_Activate, Worksheet_Deactivate. Both are Private Subs. ActiveX Control code is also stored in these modules. I.E. if you place a Control Toolbox Command Button in a worksheet, its code goes in that sheet's module.
General Subs, which can be called from anywhere in the workbook go in General Modules, which you place by going to Insert-->Module. Converse to ActiveX controls, Forms controls are assigned macros stored in General modules.