Hello,
I am writing a program to track a person's training in excel 2010. New personnel will be added to this program every month. A new userform will be created for every person when they are added into this program and will be modified depending on the person's actions. I have no issues creating the form, my problem comes in when I try to show the form by choosing their name from a combobox. I can get it to work if I assign a name to the userform, but then I am restricted by what I can name the form. I am trying to add a first and last name, but if I don't type it perfectly I get an error message. I would like to reference the forms by their captions if it is at all possible. Here is what I have but it keeps giving me this error message: "run-time error '91' Object variable or With block variable not set":
Private Sub cboSupervisors_Change()
Dim i As Integer
Dim UserForm As Object
With ufHome 'a userform named "ufHome"
For i = 1 To 100
If UserForm(i).Caption = cboSupervisors.Value Then
VBA.UserForms.Add(UserForm(i)).Show
Exit For
End If
Next i
End With
cboSupervisors.Value = ""
End Sub
Any and all help will be greatly appreciated. Thank you.
I am writing a program to track a person's training in excel 2010. New personnel will be added to this program every month. A new userform will be created for every person when they are added into this program and will be modified depending on the person's actions. I have no issues creating the form, my problem comes in when I try to show the form by choosing their name from a combobox. I can get it to work if I assign a name to the userform, but then I am restricted by what I can name the form. I am trying to add a first and last name, but if I don't type it perfectly I get an error message. I would like to reference the forms by their captions if it is at all possible. Here is what I have but it keeps giving me this error message: "run-time error '91' Object variable or With block variable not set":
Private Sub cboSupervisors_Change()
Dim i As Integer
Dim UserForm As Object
With ufHome 'a userform named "ufHome"
For i = 1 To 100
If UserForm(i).Caption = cboSupervisors.Value Then
VBA.UserForms.Add(UserForm(i)).Show
Exit For
End If
Next i
End With
cboSupervisors.Value = ""
End Sub
Any and all help will be greatly appreciated. Thank you.