You may come across times where you write a beautiful Excel macro with lots of nifty VBA code and when you go to execute the code, your screen flickers/flashes rapidly. This is caused because you more than likely have parts of your code that is effectively changing results within Excel and with Excel being a visual representation of your data, it’s going to try to show all the changes your VBA macros are doing in real time.
There’s one problem though….VBA code execution moves at a much faster pace than what your computer graphics can show. Therefore they have to meet in the middle, meaning your VBA slows down and your graphics move as fast as they can. This ultimately causes your screen to flicker.
How To Fix The Screen Flickers
So how do you fix this? Luckily, the answer is very straight forward. You prevent your screen from changing until your VBA code has finished doing its thing!
All you need to add to the beginning of your code is the following line of VBA (I usually stick it right after all my Dim statements)
'Prevent Computer Screen from running
Application.ScreenUpdating = False
'Insert your macro code here......
'Allow Computer Screen to refresh (not necessary in most cases)
Application.ScreenUpdating = True
Most coders would suggest you turn your ScreenUpdating property back on at the end of your code (so-called “Best Practice”). But technically, the screen updating automatically turns back on after your macro code has finished running. So I’ll leave it up to you to decide if you want to include the extra line of code.
Hope that helped!