Vba avoid cell update during macro execution in Excel
For example, I have a very complex macro that runs for few seconds. While the macro runs, the screen updates based on actions being performed by macro. Is there a way to avoid this updating during macro execution?
To do it in Excel, here is the answer:
- Option Explicit
- Sub SubRoutineSample()
- Application.ScreenUpdating = False
- ' complex
- ' macro
- ' function
- ' goes here
- Application.ScreenUpdating = True
- End Sub
a) Line 3 - Turn OFF Screen Updates when macro is running. Avoiding of screen refresh using this command speeds up execution.
b) Lines 4-7 - Actual macro code with functionality goes here.
c) Line 8 - Turn ON Screen Updates after macro is executed.