I am confused by the procedure to call two different userforms at different times from different modules.
I have the following two userforms named: "UserForm1" and "UserForm2", on "UserForm1" I also have a static button with code named: "Private Sub UserForm_Click()"
The subs from the forms contain the following code:
Via name: UserForm1:
[On userform1 I have a button:]
private sub OKButton_Click()
msgbox("OKButton_Click via 1")
End Sub
Public Sub UserForm1_Initialize()
msgbox("UserForm1_Initialize via 1")
'dynamic form initialisation
End Sub
Private Sub UserForm_Click()
msgbox("UserForm_Click via 1")
End Sub
VIA name: UserForm2
Public Sub UserForm_Initialize()
msgbox("UserForm_Initialize via 2")
'dynamic form initialisation
End Sub
And I call the two userforms in:
Module57
Sub Vitamins()
UserForm2.Show 'Initialising Userform2
end sub
Module53
Sub fix_ratios()
UserForm1.Show 'Initialising Userform1
end sub
The problem occurs when I call either one, at first I could not call Userform2 when UserForm1 worked fine, so I altered the name and code of UserForm2 by doubleclicking the object of UserForm2, which then created the new code:
Private Sub UserForm_Initialize()
End Sub
So I pasted my code for initializing UserForm2 in there, it worked fine. But I now realise that it just steals the "UserForm_Initialize()" from the first UserForm.
So I tried altering the subnames to:
Public Sub UserForm1_Initialize()
end sub
and
Public Sub UserForm2_Initialize()
end sub
But then it won't call the UserForms anymore. Would anyone have a suggestion, or be able to tell me what I'm doing wrong?