bbsags
04-08-2013, 02:15 PM
Hi guys i am new to VBA and have the following issue, i have a combox set up but when i am using the clear command it is clearing everything from the field and not displaying anything in the box.
But if i have no clear command as per the code below then the values in the box are doubleing and so on every time the drop button is clicked.
Is there a way to prevent this?
Private Sub ComboBox2_dropbuttonclick()
With ComboBox1
If .value = "UNITY" Then
ComboBox2.AddItem ("MFC")
ComboBox2.AddItem ("HPL")
ComboBox2.AddItem ("SGL")
ComboBox2.AddItem ("Colourcoat")
End If
If .value = "QUANTUM" Then
ComboBox2.AddItem ("MFC")
ComboBox2.AddItem ("HPL")
ComboBox2.AddItem ("SGL")
End If
End With
End Sub
But if i have no clear command as per the code below then the values in the box are doubleing and so on every time the drop button is clicked.
Is there a way to prevent this?
Private Sub ComboBox2_dropbuttonclick()
With ComboBox1
If .value = "UNITY" Then
ComboBox2.AddItem ("MFC")
ComboBox2.AddItem ("HPL")
ComboBox2.AddItem ("SGL")
ComboBox2.AddItem ("Colourcoat")
End If
If .value = "QUANTUM" Then
ComboBox2.AddItem ("MFC")
ComboBox2.AddItem ("HPL")
ComboBox2.AddItem ("SGL")
End If
End With
End Sub