Hi,
I've got two dependent comboboxes. Depending on value selected in "cmbExpTransportSlag" the second one "cmbExpDest" gets filled with a destination list.
When I then select a destination on the second box and go to another sheet tab and then back (for example) above macro triggers again without any apparent reason (atleast according to me ) and resets cmbExpDest to value "— Välj destination —".
Here is the code for cmbbox no 2:
How to work around this issue?
Is it better to use another event?
I've got two dependent comboboxes. Depending on value selected in "cmbExpTransportSlag" the second one "cmbExpDest" gets filled with a destination list.
Code:
Private Sub cmbExpTransportSlag_Change()
Dim selection As Long
Application.EnableEvents = False
Application.ScreenUpdating = False
selection = cmbExpTransportSlag.ListIndex
'Debug.Print selection
'kollar vilken produkt man valt
If selection = 1 Or selection = 2 Then
With cmbExpDest
.ListFillRange = "rSjödest"
.ListIndex = 0
.Value = " — Välj destination —"
End With
Else
'om man valt flyg
With cmbExpDest
.ListFillRange = "rFlygdest"
.ListIndex = 0
.Value = " — Välj destination —"
End With
End If
If cmbExpTransportSlag.Value = "Sjöfrakt FCL" Then
With cmbFCLUtr
.Visible = True
.ListFillRange = "ExportFCLAlt"
.Value = "— Välj containertyp —"
End With
Range("B15").Value = "Containertyp"
Else
On Error Resume Next
cmbFCLUtr.Visible = False
Range("B15").ClearContents
End If
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
Here is the code for cmbbox no 2:
Code:
Private Sub cmbExpDest_Change()
Application.EnableEvents = False
Application.ScreenUpdating = False
If cmbExpTransportSlag.Value = "Flygfrakt" Then
Worksheets("AE Rates").Range("AEDest").Value = cmbExpDest.Value
End If
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
Is it better to use another event?