ajsmith68502
New Member
- Joined
- Sep 20, 2016
- Messages
- 9
Sorry if this has been asked before, but I can't find an answer. I have a userform with multiple comboboxes and the second one has to be chosen twice to keep it's value. Not sure why. The others are fine. Here's the code:
Private Sub UserForm_Initialize()
Application.EnableEvents = False
'Clear
UserForm1.cbFamily.Value = ""
UserForm1.cbNS1.Value = ""
UserForm1.cbNS1.Visible = False
UserForm1.cbNS2.Visible = False
UserForm1.lblNS1.Visible = False
UserForm1.lblNS2.Visible = False
'------------------------------------------Accessory list populates
With cbFamily
.AddItem "Cone"
.AddItem "Bellow"
.AddItem "Bellow with 90° Elbow"
.AddItem "Elbow"
.AddItem "Elbow - 90° Mitred"
.AddItem "Flex"
.AddItem "Flex with 90° Elbow"
.AddItem "Outlet Extension 45° Cut with Bird Screen"
.AddItem "Tube"
End With
Application.EnableEvents = True
End Sub
Private Sub cbFamily_Click()
Application.EnableEvents = False
'-----------------------------------------cbNS1 populates
Dim index As Integer
index = cbFamily.ListIndex
Select Case index
'----------------Cone NS1
Case Is = 0
With cbNS1
.AddItem "8"
.AddItem "10"
.AddItem "12"
.AddItem "14"
.AddItem "16"
.AddItem "18"
.AddItem "20"
.AddItem "22"
.AddItem "24"
.AddItem "26"
.AddItem "28"
.AddItem "30"
End With
'----------------Bellow NS1
Case Is = 1
With cbNS1
.AddItem "4"
.AddItem "5"
.AddItem "6"
.AddItem "8"
.AddItem "10"
.AddItem "12"
.AddItem "14"
.AddItem "16"
.AddItem "18"
.AddItem "20"
.AddItem "22"
.AddItem "24"
.AddItem "26"
.AddItem "28"
.AddItem "30"
End With
'----------------Bellow with 90° Elbow NS1
Case Is = 2
With cbNS1
.AddItem "5"
.AddItem "6"
.AddItem "8"
.AddItem "10"
.AddItem "12"
End With
'----------------Elbow NS1
Case Is = 3
With cbNS1
.AddItem "2.5"
.AddItem "3"
.AddItem "3.5"
.AddItem "4"
.AddItem "5"
.AddItem "6"
.AddItem "8"
.AddItem "10"
.AddItem "12"
End With
'----------------Elbow - 90° Mitred NS1
Case Is = 4
With cbNS1
.AddItem "10"
.AddItem "12"
.AddItem "14"
.AddItem "16"
.AddItem "18"
.AddItem "20"
.AddItem "22"
.AddItem "24"
.AddItem "26"
.AddItem "28"
.AddItem "30"
End With
'--------------------Flex NS1
Case Is = 5
With cbNS1
.AddItem "2.5"
.AddItem "3"
.AddItem "3.5"
.AddItem "4"
.AddItem "5"
.AddItem "6"
.AddItem "8"
.AddItem "10"
.AddItem "12"
End With
'--------------------Flex with 90° Elbow NS1
Case Is = 6
With cbNS1
.AddItem "5"
.AddItem "6"
.AddItem "8"
.AddItem "10"
.AddItem "12"
End With
'------------------------Outlet Extension 45° Cut with Bird Screen
Case Is = 7
With cbNS1
.AddItem "5"
.AddItem "6"
.AddItem "8"
.AddItem "10"
.AddItem "12"
.AddItem "14"
.AddItem "16"
.AddItem "18"
.AddItem "20"
.AddItem "22"
.AddItem "24"
.AddItem "26"
.AddItem "28"
.AddItem "30"
End With
'--------------------Tube NS1
Case Is = 7
With cbNS1
.AddItem "2"
.AddItem "2.5"
.AddItem "3"
.AddItem "3.5"
.AddItem "4"
.AddItem "5"
.AddItem "6"
.AddItem "8"
.AddItem "10"
.AddItem "12"
.AddItem "14"
.AddItem "16"
.AddItem "18"
.AddItem "20"
.AddItem "22"
.AddItem "24"
.AddItem "26"
.AddItem "28"
.AddItem "30"
End With
End Select
UserForm1.cbNS1.Visible = True
UserForm1.lblNS1.Visible = True
Application.EnableEvents = True
End Sub
Private Sub cbNS1_Click()
Application.EnableEvents = False
UserForm1.cbNS2.Visible = True
UserForm1.lblNS2.Visible = True
'------------------------------------------cbNS2 Populates
Dim index As Integer
index = cbNS1.ListIndex
Select Case index
'---------------
Case Is = 0
With cbNS2
.AddItem "8"
.AddItem "10"
.AddItem "12"
End With
Case Is = 1
With cbNS2
.AddItem "Test"
End With
Case Is = 2
With cbNS2
.AddItem "1"
.AddItem "2"
End With
End Select
Application.EnableEvents = True
End Sub
Private Sub UserForm_Initialize()
Application.EnableEvents = False
'Clear
UserForm1.cbFamily.Value = ""
UserForm1.cbNS1.Value = ""
UserForm1.cbNS1.Visible = False
UserForm1.cbNS2.Visible = False
UserForm1.lblNS1.Visible = False
UserForm1.lblNS2.Visible = False
'------------------------------------------Accessory list populates
With cbFamily
.AddItem "Cone"
.AddItem "Bellow"
.AddItem "Bellow with 90° Elbow"
.AddItem "Elbow"
.AddItem "Elbow - 90° Mitred"
.AddItem "Flex"
.AddItem "Flex with 90° Elbow"
.AddItem "Outlet Extension 45° Cut with Bird Screen"
.AddItem "Tube"
End With
Application.EnableEvents = True
End Sub
Private Sub cbFamily_Click()
Application.EnableEvents = False
'-----------------------------------------cbNS1 populates
Dim index As Integer
index = cbFamily.ListIndex
Select Case index
'----------------Cone NS1
Case Is = 0
With cbNS1
.AddItem "8"
.AddItem "10"
.AddItem "12"
.AddItem "14"
.AddItem "16"
.AddItem "18"
.AddItem "20"
.AddItem "22"
.AddItem "24"
.AddItem "26"
.AddItem "28"
.AddItem "30"
End With
'----------------Bellow NS1
Case Is = 1
With cbNS1
.AddItem "4"
.AddItem "5"
.AddItem "6"
.AddItem "8"
.AddItem "10"
.AddItem "12"
.AddItem "14"
.AddItem "16"
.AddItem "18"
.AddItem "20"
.AddItem "22"
.AddItem "24"
.AddItem "26"
.AddItem "28"
.AddItem "30"
End With
'----------------Bellow with 90° Elbow NS1
Case Is = 2
With cbNS1
.AddItem "5"
.AddItem "6"
.AddItem "8"
.AddItem "10"
.AddItem "12"
End With
'----------------Elbow NS1
Case Is = 3
With cbNS1
.AddItem "2.5"
.AddItem "3"
.AddItem "3.5"
.AddItem "4"
.AddItem "5"
.AddItem "6"
.AddItem "8"
.AddItem "10"
.AddItem "12"
End With
'----------------Elbow - 90° Mitred NS1
Case Is = 4
With cbNS1
.AddItem "10"
.AddItem "12"
.AddItem "14"
.AddItem "16"
.AddItem "18"
.AddItem "20"
.AddItem "22"
.AddItem "24"
.AddItem "26"
.AddItem "28"
.AddItem "30"
End With
'--------------------Flex NS1
Case Is = 5
With cbNS1
.AddItem "2.5"
.AddItem "3"
.AddItem "3.5"
.AddItem "4"
.AddItem "5"
.AddItem "6"
.AddItem "8"
.AddItem "10"
.AddItem "12"
End With
'--------------------Flex with 90° Elbow NS1
Case Is = 6
With cbNS1
.AddItem "5"
.AddItem "6"
.AddItem "8"
.AddItem "10"
.AddItem "12"
End With
'------------------------Outlet Extension 45° Cut with Bird Screen
Case Is = 7
With cbNS1
.AddItem "5"
.AddItem "6"
.AddItem "8"
.AddItem "10"
.AddItem "12"
.AddItem "14"
.AddItem "16"
.AddItem "18"
.AddItem "20"
.AddItem "22"
.AddItem "24"
.AddItem "26"
.AddItem "28"
.AddItem "30"
End With
'--------------------Tube NS1
Case Is = 7
With cbNS1
.AddItem "2"
.AddItem "2.5"
.AddItem "3"
.AddItem "3.5"
.AddItem "4"
.AddItem "5"
.AddItem "6"
.AddItem "8"
.AddItem "10"
.AddItem "12"
.AddItem "14"
.AddItem "16"
.AddItem "18"
.AddItem "20"
.AddItem "22"
.AddItem "24"
.AddItem "26"
.AddItem "28"
.AddItem "30"
End With
End Select
UserForm1.cbNS1.Visible = True
UserForm1.lblNS1.Visible = True
Application.EnableEvents = True
End Sub
Private Sub cbNS1_Click()
Application.EnableEvents = False
UserForm1.cbNS2.Visible = True
UserForm1.lblNS2.Visible = True
'------------------------------------------cbNS2 Populates
Dim index As Integer
index = cbNS1.ListIndex
Select Case index
'---------------
Case Is = 0
With cbNS2
.AddItem "8"
.AddItem "10"
.AddItem "12"
End With
Case Is = 1
With cbNS2
.AddItem "Test"
End With
Case Is = 2
With cbNS2
.AddItem "1"
.AddItem "2"
End With
End Select
Application.EnableEvents = True
End Sub