Hello,
I have a few two comboboxes filled with a dynamic range based on INDEX with no linked cells. These two are dependant. My problem is that the trigger each other so that a simple calculation that should be almost instant takes 3-4 seconds. It's not a show stopper but pretty annoying.
Here is my code:
Thanks for any suggestions on how to improve.
BR
Percy
I have a few two comboboxes filled with a dynamic range based on INDEX with no linked cells. These two are dependant. My problem is that the trigger each other so that a simple calculation that should be almost instant takes 3-4 seconds. It's not a show stopper but pretty annoying.
Here is my code:
Code:
Option Explicit
Private Sub cmbExpDest_Change()
Application.EnableEvents = False
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
If cmbExpTransportSlag.Value = "Flygfrakt" Then
Worksheets("AE Rates").Range("AEValdDest").Value = cmbExpDest.Value
End If
Application.EnableEvents = True
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
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 = "AEDestReg"
.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
Private Sub cmbExpTransportSlag_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 9 Then cmbExpDest.Activate
End Sub
Private Sub cmbExpDest_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
Application.EnableEvents = False
Application.ScreenUpdating = False
If KeyCode = 9 And cmbFCLUtr.Visible = True Then
cmbFCLUtr.Activate
Debug.Print KeyCode
ElseIf KeyCode = 9 And cmbFCLUtr.Visible = False Then
Range("I21").Activate
End If
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
Private Sub Worksheet_Activate()
With cmbExpTransportSlag
.ListIndex = -1
.Value = "— Välj produkt —"
End With
Range("FaktiskVikt").Value = ""
Range("FaktiskVolym").Value = ""
End Sub
Thanks for any suggestions on how to improve.
BR
Percy