Creating first ever userform but not going how I wanted
I am in the process of creating my first userform. I am having much
difficulty though as the information in the Office help is not pertinent to
what I am trying to do.
I am looking to find the flaws in these codes:
Private Sub UserForm_Initialize()
cbxData.Enabled = False
cmdOK = False
End Sub
Private Sub cbxFilter_Change()
cbxData.Enabled = True
cmdOK = False
Dim Department() As Variant
Dim Rank() As Variant
Dim Sex() As Variant
If cbxFilter.Value = "DEPARTMENT" Then
cbxData.RowSource = "Department"
'Department = VBA.Array("Department", _
"Accounting", _
"Finance", _
"Management")
ElseIf cbxFilter.Value = "RANK" Then
cbxData.RowSource = "Rank"
'Rank = VBA.Array("Rank", _
"Assistant", _
"Associate", _
"Full", _
"Instructor")
ElseIf cbxFilter.Value = "SEX" Then
cbxData.RowSource = "Sex"
'Sex = VBA.Array("Sex", _
"F", _
"M")
End If
End Sub
Private Sub cmdCancel_Click()
Unload SelectCriteria
End Sub
Private Sub cmdOK_Click()
If cbxFilter.Value = "Department" Then
Load cbxData.Value = Range("c2")
ElseIf cbxFilter.Value = "Rank" Then
Load cbxData.Value = Range("d2")
ElseIf cbxFilter.Value = "Sex" Then
Load cbxData.Value = Range("f2")
End If
Me.Hide
End Sub
If I can get over this problem then I hopefully can activate my userform can
be run smoothly.
Thank you in advance for your help.
|