Is there any effect if I do not restore the application.calculation in vba?
I have turned off the
application.calculation = xlcalculationmanual
and after such a lengthy vba code I have done these at the end
application.calculation = xlcalculationautomatic
What I saw is these statement is taking 20 seconds and sometimes hanging up when I restore the xlcalculation
application.calculation = xlcalculationautomatic
I really do not understand why it is taking a lot of time for that statement. To save the time, I just neglected to rest开发者_开发知识库ore it. Is there any effect if I do not restore it back?
The consequence is that no calculations will be done. So if you have a cell with formula =A1+A2
and you change the values of A1 and A2, then the result won't be updated to the actual sum of the current values of A1 and A2 until you force a calculation manually F9 or select automatic calculation again. This can also be done manually in Tools > Options... > Calculation.
What I suspect is happening is that it it re-calculating the enture workbook.
Ideally, you should not disable automatic calculations because this is dangerous. (i.e. you may be looking at old cached values instead of recent values)
Instead you should verify that the problem is recalculation (i.e. manually recalculate the sheet and see how long it takes). If that is the problem, you should google way of speeding up calculations (i.e. splitting up your data, using static references, etc...)
精彩评论