In my Excel spreadsheet I use the below VBA codes to get a UserForm
with a ComboBox using the values from sheet1
:
List for ComboBox1 on spreadsheet:
A B
1 Q1
2 Q2
3 Q3
4 Q4
VBA code to call UserForm1 (connected to a button on the spreadsheet):
Sub Test()
Call UserForm1.Show(vbModeless)
End Sub
VBA code of UserForm1:
Private Sub UserForm_Activate()
ComboBox1.List = Sheet1.Range("A1:A4").Value
End Sub
Private Sub CommandButton1_Click()
Unload UserForm1
End Sub
All this works fine so far. However, when the user pushes the button to load the UserForm1
the entire spreadsheet is re-calculated by Excel which takes a lot of time.
Therefore, I tried to change the code to this:
Sub Test()
Application.Calculation = xlManual
Call UserForm1.Show(vbModeless)
Application.Calculation = xlAutomatic
End Sub
With this code the UserForm1
is loaded without re-calculating the spreadsheet.
However, since I do not want to keep the spreadsheet in the "manual" re-calculating mode I have to set it back to "automatic" within the VBA code.
However, this causes the same problem of the long loading time. The only difference is that the re-calculation now happens after the UserForm
is displayed.
Is it possible to load the entire UserForm
without re-calculating the spreadsheet but keep it in automatic calculation mode?