VBA Screen Updating Property

Excel VBA Screen Updating

VBA Screen Updating is a property used to avoid or prevent distraction flashes while running the code and make it fast by turning off Screen Updating. We can turn off the screen updating by setting this property as false.

Often times we can feel the excel screen goes crazy while the macro is running, and we almost get frustrated by that. But how do we deal with these situations and make the code run faster than the usual slow thing?

Screen Updating is something we can notice while the excel macroExcel MacroMacro in excel is a series of instructions in code that helps automate manual tasks, thereby saving time. Excel executes those instructions in a step-by-step manner on the given data. read more is running. When the task is executing, we can notice our screen is updating the values until the macro finishes its assigned task. As our screen flickering or refreshing, it leads to the slowdown of the excel program and takes a longer time than usual to complete the task.

In VBA, we have a property called “ScreenUpdating,” and we set this property to FALSE so that it will eliminate the process of screen updating while the code is running.

In this article, we will say goodbye to the watching of on-screen action drama while the code is running. Today you will make your code run faster and quicker than your usual time.

VBA-Screen-Updating

You are free to use this image on your website, templates etc, Please provide us with an attribution linkHow to Provide Attribution?Article Link to be Hyperlinked
For eg:
Source: VBA Screen Updating Property (wallstreetmojo.com)

When to use Screen Updating Feature?

Suppose you have any doubt when to use this technique. Look into the below points.

How to use Screen Updating Feature in VBA Code?

You can download this VBA ScreenUpdating Excel Template here – VBA ScreenUpdating Excel Template

Example #1 – Turn Off Screen Updating

For example, look at the below code.

Code:

Sub Screen_Updating()

 Dim RowCount As Long
 Dim ColumnCount As Long
 Dim MyNumber As Long

 MyNumber = 0

 For RowCount = 1 To 50

 For ColumnCount = 1 To 50
   MyNumber = MyNumber + 1
   Cells(RowCount, ColumnCount).Select
   Cells(RowCount, ColumnCount).Value = MyNumber
 Next ColumnCount

 Next RowCount

End Sub

The above has a nested VBA loopVBA LoopLoops are commonly used in all of the programming languages, where there is a certain need or a criteria when we need a certain code to run a certain times. In VBA, there are several different types of loops, including Do while, Do till, For Loop, and For each loop. These loops help code to execute until the condition is met.read more to insert serial numbers from the first column to the 50th column and again comes back and insert serial number starting from 51 from the second row to the 50th column.

VBA Screen Update Example 1

Like this, it will insert until it reaches the 50th row.

While this code is running, you can notice your screen flickering, and you cannot do anything apart from watching this crazy moment.

To avoid all of these, we can add Screen Updating to FALSE.

To access the Screen Updating feature first, we need to access the Application object.

VBA Screen Update Example 1-1

As we can see with the Application object, we have many properties and methods. So, select Screen Updating from the IntelliSense list.

Note: You have to apply the Screen Updating feature immediately after the declaration of the variables.

Example 1-2

After selecting the Screen Updating property, put an equal sign (=).

Example 1-3

As we can see, two Boolean values, i.e., FALSE & TRUE.

To stop screen updating, set the status to FALSE.

Example 1-4

Now, as the macro starts running first, it will update the screen updating status to FALSE and proceed to the next line.

Since macro executed Screen Updating to FALSE, it will not allow the screen to update while the code is executing its task.

Example #2 –

Always Set Screen Updating to TRUE at the End

I have seen many people set the Screen Updating to FALSE but forgot to set it back to TRUE at the end of the macro.

Always set the Screen Updating back to TRUE at the end of the macro.

Code:

Sub Screen_Updating()

 Dim RowCount As Long
 Dim ColumnCount As Long
 Dim MyNumber As Long

 Application.ScreenUpdating = False
 MyNumber = 0

 For RowCount = 1 To 50

 For ColumnCount = 1 To 50
   MyNumber = MyNumber + 1
   Cells(RowCount, ColumnCount).Select
   Cells(RowCount, ColumnCount).Value = MyNumber
 Next ColumnCount

 Next RowCount
 Application.ScreenUpdating = True

End Sub

Recommended Articles

This has been a guide to VBA Screen Updating. Here we discuss how to use Application.ScreenUpdating feature to make code run faster and quicker than your usual time along with examples and downloadable excel template. Below are some useful excel articles related to VBA –

  • 35+ Courses
  • 120+ Hours
  • Full Lifetime Access
  • Certificate of Completion
LEARN MORE >>