Forum Discussion
Olivierb61
Feb 08, 2022Copper Contributor
Macros suddenly run much slower
I noticed that excel 365 macros suddenly take much longer to run. Seems to be correlated with the latest update of excel done on february 3rd on my machine
timfrewin
Feb 14, 2022Copper Contributor
I had this same problem. Something has clearly changed on MS's side. Some macros which used to take around 30 secs were taking anywhere from 20 mins to 2.5 hours. This was a sudden change early last week. However, we've found a fix. Once we disabled automatic formula recalculation during execution of the macro, everything went back to normal. If anything, faster than before.
At the beginning of each function:
Application.Calculation = xlCalculationManual
At the end of each function:
Application.Calculation = xlCalculationAutomatic
Or, a better way, if you want to preserve the user settings of automatic vs manual calculation following completion of the macro:
Sub x()
lCalc = Application.Calculation
With Application
.Calculation = xlCalculationManual
.ScreenUpdating = False
.DisplayAlerts = False
''///your code here
.Calculation = lCalc
.ScreenUpdating = True
.DisplayAlerts = True
End With
End Sub
(Credit to user royUK on https://www.ozgrid.com/ forum for that addition and code snippet)
DiggyWig
Mar 28, 2024Copper Contributor
timfrewin
I had this same problem. Suddenly, six days ago, a macro that I’ve been using for over ten years started taking 15 minutes to run instead of the normal 10 seconds.
Introducing those few lines of code has fixed it 🙂
Many, many thanks for sharing this … you’re a life saver.
I had this same problem. Suddenly, six days ago, a macro that I’ve been using for over ten years started taking 15 minutes to run instead of the normal 10 seconds.
Introducing those few lines of code has fixed it 🙂
Many, many thanks for sharing this … you’re a life saver.