Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ScreenUpdating = False fails in Excel 2013 and 2016

Tags:

excel

vba

Long-running, high-end Excel-based applications that I developed years ago and that run beautifully in Excel 2007 and 2010 look like Amateur Hour in Excel 2013 and 2016 because Application.ScreenUpdating = False no longer works reliably.

The screen unfreezes apparently when VBA code copies a preformatted worksheet from the macro workbook into a new workbook, although other circumstances must trigger it as well.

I’ve seen the threads on this subject that recommend “fiddling with the code” or “calling the code in a subroutine”. Unfortunately, I have to maintain hundreds of Excel applications each with thousands of lines of code and hundreds of users who are about to migrate to Office 2016, so rewriting is not an option. How can I recover Excel’s former elegance?

like image 418
Weston E Avatar asked Feb 09 '16 20:02

Weston E


2 Answers

We have been dealing with this problem now for a long time as my tools do show live animated charts which all of the sudden were completely static - we would have died for having at least a flickering animation.

Initially we tried to force the animation with a forced screenupdate but that did not work. Just by pure coincidence (copy pasted too many times) we stumbled into a solution which is equally unbelievable as it does seem to work. After each Application.ScreenUpdating = True we have added x3 times DoEvents. On some systems x2 times DoEvents works but x3 times does seem to be more reliable on the various office releases out there. Voila our animation came back :-)

Application.ScreenUpdating = True

DoEvents

DoEvents

DoEvents

We have not used it for the Application.ScreenUpdating = False statement but it might do some magic there. Anyway we hope that this road can help some of you finding creative functional solutions!

like image 99
DYNATUNE-XL Avatar answered Oct 20 '22 19:10

DYNATUNE-XL


I wanted to leave a comment but I am not allowed to do so. Without a code sample it is very dificult to understand your problem (please see https://stackoverflow.com/help/how-to-ask and edit your question appropriately.

Here are some ideas: - Check if your code calls for code in a different procedure, maybe the Application.ScreenUpdating is turned on outside of the procedure. - Try this at the beginning of your procedure:

Application.Calculation = xlCalculationManual

Then, at the end of the code set it to:

Application.Calculation = xlCalculationAutomatic

It might help; however, without a code sample it is very difficult to properly help you.

like image 43
vicsar Avatar answered Oct 20 '22 18:10

vicsar