vba avoid cell update during macro excecution in Excel

Q198. In Excel, how can I avoid updates to cell values during macro execution?

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:

  1. Option Explicit
  2. Sub SubRoutineSample()
  3. Application.ScreenUpdating = False
  4. ' complex
  5. ' macro
  6. ' function
  7. ' goes here
  8. Application.ScreenUpdating = True
  9. End Sub

Description:

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.

 

You can find similar Excel Questions and Answer hereunder

1) How can I protect / unprotect WorkSheet using VBA?

2) Highlight row of selected cell in Excel

3) how do you enter multiple line in a cell in Excel

4) How do I add a shape using VBA?

5) Vba to return week numbers in Excel

6) How can I hide a sheet completely from users (the sheet should not even appear in Unhide dialog box)?

7) Calling a macro from another workbook in Excel

8) I want to pull data from a table using a reference cell in table. Is there a function to support that?

9) How can I extract file name from a full path including folder path and file name?

10) How can I remove display of Gridlines in my worksheet using VBA?

11) How can I display fractions as it is in a cell (instead of displaying as a decimal)?

12) I want to automatically run an initialization procedure whenever I open my WorkBook so that it is ready for use - how can I achieve that?

13) How can I ensure that user enters only certain acceptable values in an input cell?

14) How can I sort data using VBA?

15) How can I find the last used cell in a Column in VBA?