Ok! This one is important.
Any good VBA procedure always has this line mentioned at the beginning.
Application.Screenupdating=FALSE
And before the end of the procedure you will see this line too.
Application.Screenupdating=TRUE
What is ScreenUpdating?
Screenupdating is the property of application objects in VBA. It can be set to TRUE or FALSE. It is like a switch, that can be turned On or Off.
And What Does it Do?
The first line speed ups the macro processing by stopping real time screen updating of Excel.
If you have a long macro that writes into different sheets, applies filters, removes filters, changes sheets, saves workbooks, etc. And if you haven't turned off screen updates using the line Application.Screenupdating=FALSE, then you will see the flickering on screen. Each and every change done by macro in the workbook will be shown dynamically. This slows down the macro speed.
And If you have this line at the beginning of macro, excel will not reflect changes done by macro until screenupdating is turned on using the line Application.Screenupdating=TRUE.
If you want to speed up your macro, disable the screen update at the beginning of subroutine and enable the screen update before the end of subroutine.
Here's one Example:
Sub Screencheck() Application.Screenupdating=FALSE 'Disabling the screen updating. Sheet1.Activate Range("A1").value ="Hi" Range("A2").value ="How are you?" Range("A3").value ="Exceltip is amazing, isn't it?" Sheet2.Activate Application.Screenupdating= TRUE 'Enabling the screen updating. End Sub
When you run the above sub you will not see any screen flickering. You will see the final result of work done by this macro.
Important Notes:
Make sure that you enable the screen update before your procedure ends. If you don't enable the screen update, you will not be able to see the work done by the macro.
Unable screen updating before every Exit Sub and End Sub command. It is common to forget enabling screen updates before Exit Sub. If you don't do this, you may keep wondering why your code didn't work. But in reality, it did. You just can't see it.
That's it. This is what Application.Screenupdating = False does in VBA. This one line of code changes a lot. It is the difference between mature programming and careless programming. If you want to speed up your macro, always use this line in your code.
I hope this was helpful to you. If you have any doubts regarding this article or have any other Excel/VBA related questions, feel free to ask in the comments section below. I'll be happy to help.
Related Articles:
What is the difference Between ByRef and ByVal Arguments? :This is an important VBA Question. The ByVal and ByRef are used to pass arguments differently. One lets the change be made in the original variable while the other does not alter the original variable.
How To Loop Through Sheets In Excel Using VBA : While automating the usual boring tasks of excel in VBA, you’ll get the need to loop through each sheet. Let's start with an example. VBA Code to Loop in all sheets in Activeworkbook and print sheet Name
Events in Excel VBA: Sometimes we want something to happen automatically when a certain event occurs. To do something when a specific event happens in Excel, we use Excel VBA event
Popular Articles:
50 Excel Shortcuts to Increase Your Productivity | Get faster at your task. These 50 shortcuts will make you work even faster on Excel.
The VLOOKUP Function in Excel | This is one of the most used and popular functions of excel that is used to lookup value from different ranges and sheets.
COUNTIF in Excel 2016 | Count values with conditions using this amazing function. You don't need to filter your data to count specific values. Countif function is essential to prepare your dashboard.
How to Use SUMIF Function in Excel | This is another dashboard essential function. This helps you sum up values on specific conditions.
The applications/code on this site are distributed as is and without warranties or liability. In no event shall the owner of the copyrights, or the authors of the applications/code be liable for any loss of profit, any problems or any damage resulting from the use or evaluation of the applications/code.