Slinfoot
01-07-2014, 10:26 AM
Hi Vbax users
I'm creating a number of userforms and at the top of these forms I am adding a combo box and a spin button.
The function of these controls does the same thing on each form so I'm trying to create a Public Sub in a module which will create these controls.
But I am getting a Type-Mismatch error.
These test I've done so far is as follow:
Code in Module1:
Public Sub SiteSelector(CurrentForm as Userform)
Dim TestCombo as MSForms.ComboBox
Set TestCombo = CurrentForm.Controls.Add("Forms.ComboBox.1", "TestCombo", True)
End Sub
Code in form(I applied it to a button click event):
Private Sub CommandButton1_Click
Module1.SiteSelector(Me)
End Sub
Thanks in advance
I'm creating a number of userforms and at the top of these forms I am adding a combo box and a spin button.
The function of these controls does the same thing on each form so I'm trying to create a Public Sub in a module which will create these controls.
But I am getting a Type-Mismatch error.
These test I've done so far is as follow:
Code in Module1:
Public Sub SiteSelector(CurrentForm as Userform)
Dim TestCombo as MSForms.ComboBox
Set TestCombo = CurrentForm.Controls.Add("Forms.ComboBox.1", "TestCombo", True)
End Sub
Code in form(I applied it to a button click event):
Private Sub CommandButton1_Click
Module1.SiteSelector(Me)
End Sub
Thanks in advance