How To Stop Screen Flickering While Running VBA Macros in Excel

By Chris Newman •  Updated: 01/17/19 •  2 min read
Excel VBA Prevent Screen Flickering Flashing

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)

Sub PreventScreenFlicker()

'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

End Sub

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!

Keep Learning

Chris Newman

Chris Newman

Chris is a finance professional and Excel MVP recognized by Microsoft since 2016. With his expertise, he founded TheSpreadsheetGuru blog to help fellow Excel users, where he shares his vast creative solutions & expertise. In addition, he has developed over 7 widely-used Excel Add-ins that have been embraced by individuals and companies worldwide.

[FREE Training] 10 Amazing Excel Efficiency Tricks. Why Don't People Know These?!