|
-
Jun 28th, 2012, 04:31 AM
#1
Thread Starter
Lively Member
[RESOLVED] getting a private sub to run on startup
Hi
I have a private sub routine called 'initProductForm' and this does everything I want when called from a click event; initialises listboxes, populates listboxes, sets screen messages to blank, etc.
I want the routine to run when the workbook opens and rather than duplicate the code I would like to call the routine when the workbook opens.
How best to go about achieving this?
Thanks
-
Jun 28th, 2012, 05:44 AM
#2
Re: getting a private sub to run on startup
put
initProductForm.show
in the workbook open event
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jun 29th, 2012, 11:11 AM
#3
Thread Starter
Lively Member
Re: getting a private sub to run on startup
Isn't that for calling a form?
Sorry, I should have been clearer in my original post.
I have a sub routine in 'sheet1' called 'InitProduct' and this is a few lines of code that populates a listbox. I want the same code to run whenever the workbook opens but I don't want to copy / paste the same code to different modules.
So in 'Thisworkbook' module I have a call to 'InitProduct' but the procedure is not found.
Is there a way from the 'Thisworkbook' module to call sheet1 module called 'InitProduct'?
Thanks
-
Jun 29th, 2012, 04:32 PM
#4
Re: getting a private sub to run on startup
prefix with sheet
make sure sub procdure is not private
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|