nzclogger1
New Member
- Joined
- Oct 2, 2014
- Messages
- 16
I currently have the following macro structure - how this takes about 4 minutes to run in its current state. Would love any ideas on how to speed up the macro (I've simplified this down a bit). Note this is part of a user form, so the macro is initiated by the click of the OK button
Each of the additional macros that are called upon in the code below are structured like this (the intention is to try to get rid of screen updating and automatic calculation, however currently the screen is updating and the cells are autorecalculating - this is what I'm trying to achieve to speed up the macro, but it isn't working).
Code:
Private Sub OK_button_Click()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Range("A1").Value = Level1 'Level1 is a text string in a combo box in the user form
Range("A2").Value = Level2 'Level2 is a text string in a combo box in the user form
...
Range("A5").Value = WorksheetFunction.CountA(Range("A1:A4")) - WorksheetFunction.CountIf(Range("A1:A4"), "")
If Range("A5").Value = 1 Then
If Level1 = "Assets" Or Level1 = "Liabilities" Or Level1 = "Equity" Then
Call Level1_BS_Macro1
Call Level1_BS_Macro2
...
ElseIf Level1 = "Income" Or Level1 = "Expenses" Or Level1 = "Tax refund" Or Level1 = "Tax" Then
Call Level1_IS_Macro1
Call Level1_IS_Macro2
ElseIf Range("A5").Value = 2 then
If Level1 = "Assets" Or Level1 = "Liabilities" Or Level1 = "Equity" Then
Call Level2_BS_Macro1
Call Level2_BS_Macro2
...
ElseIf Level1 = "Income" Or Level1 = "Expenses" Or Level1 = "Tax refund" Or Level1 = "Tax" Then
Call Level2_IS_Macro1
Call Level2_IS_Macro2
...
End If
Sheets("Inputs").Select
Range("A1:A5").Select
Selection.ClearContents
Range("A1").Select
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
Unload Me
End Sub
Each of the additional macros that are called upon in the code below are structured like this (the intention is to try to get rid of screen updating and automatic calculation, however currently the screen is updating and the cells are autorecalculating - this is what I'm trying to achieve to speed up the macro, but it isn't working).
Code:
Private Sub Level1_BS_Macro1()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
[Additional code - e.g. adding rows]
End Sub