none
Excel 2007 vba - Multiple Userform use

    Question

  • Hi,

    When in a workbook one has more than one UserForm does each one has to have a "UserForm_Initialize?"

    I have 2 userform that I am using, the first one contains a selection of WBS, the second one has two comboBox and 5 textBox, the third one has a progress bar. the firts one to come up on the screen when the application starts is the selection of WBS then once the selection has been made by the user, the second one with the ComboBox must be displayed and the first one must be hidden at last when the appropriate selection are made by the user then that form is hidden and the progress bar is up and progress starts. can someone provide me with sample on how to do that.

    Should each of the userform have their own "userform_initialize" if yes, then should each of the userform_Initialize be named according to the name of the form itself. e.g.: In my case I have UfWBS (WBS form), UfSel (Combo Selection form) and finally the UfBar (Progress bar form).

    Should I put "Private Sub UfWBS_Initialize()" instead of "Private Sub UserForm_Initialize()"

    Yours help would be appreciated.

    Thanks in Advance!

    Chuck

    Friday, April 27, 2012 2:52 AM

Answers

  • The code for each userform resides in each userform's private codemodule, so they can (and must) all have the same name -  "userform_initialize". You only need to have the specific userform's name when you are calling a form from other codemodules.


    HTH, Bernie

    Friday, April 27, 2012 3:43 AM
  • Thanks Bernie for the clarification. I am not a programmer and newly using vba and enjoying it.

    Cheers!

    Chuck

    • Marked as answer by chamdan Friday, April 27, 2012 3:57 AM
    Friday, April 27, 2012 3:57 AM

All replies

  • The code for each userform resides in each userform's private codemodule, so they can (and must) all have the same name -  "userform_initialize". You only need to have the specific userform's name when you are calling a form from other codemodules.


    HTH, Bernie

    Friday, April 27, 2012 3:43 AM
  • Thanks Bernie for the clarification. I am not a programmer and newly using vba and enjoying it.

    Cheers!

    Chuck

    • Marked as answer by chamdan Friday, April 27, 2012 3:57 AM
    Friday, April 27, 2012 3:57 AM