How to speed up macro

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

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
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
well nz

Pretty obvious question... why remove code from your post then ask for help speeding it up ? (may explain the lack of responses)

Also maybe the code you are comfortable with is the reason its slow?

furthermore sizes and volumes how big is the workbook, how many open what sort of linkage is there on sheet, between sheets and between workbooks, inserting rows in 100,000 row data set with formula's cross referenced.... maybe quite slow

but from what you've posted this thing should run in the blink of an eye
 
Upvote 0

Forum statistics

Threads
1,225,149
Messages
6,183,194
Members
453,151
Latest member
Lizamaison

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