Comboboxes triggering each other making calculation slow

percy83

Active Member
Joined
Mar 11, 2009
Messages
278
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:

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
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Forum statistics

Threads
1,224,599
Messages
6,179,831
Members
452,946
Latest member
JoseDavid

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top