Multiple Private Sub UserForm_Initialize() on same userform

  • Hello,


    I am having trouble using multiple "Private Sub UserForm_Initialize()" on the same userform which are doing different things. I am not a expert and not sure if we can use the multiple Sub UserForm Initialize () events.


    Can someone please guide me the way how to do it if there is a way to do it? thanks in advance

  • Re: Multiple Private Sub UserForm_Initialize() on same userform


    Initialize is an event of the user form, the code runs when the user form is initialized, you can't have more than one initialize routine and in any case you can't have any routine with the same name, you will get an ambiguous name error, meaning the code doesn't know which one you are trying to run. If you are copying the first line and adding a 1 etc. to the end of the name then Excel just sees that as a routine you made up and doesn't run it just because the user form has been initialized.


    If you had kids all with the same name and you yell out that name, they don't know which one of them you are calling.


    You can call other code from the initialize code, but you can only have the one module that is triggered by the user form initializing.

    Bruce :cool: