Search code examples
excelexcel-2007excel-2010vba

Screenupdating not flipping


In Excel 2010 the method described below, the ScreenUpdating works correctly. But in 2007, it doesnt flip and the worksheet operations are visually being seen.

VBA Usage:

Dim scrup As Boolean: scrup = DisableScreenUpdating(Application.ScreenUpdating)

Method Declaration:

Function DisableScreenUpdating(val As Boolean) As Boolean
   '''''''''''''''''''''''''''''''''''''''''''''''''
   ' Disable ScreenUpdating, for seemless operation
   If val Then
      Application.ScreenUpdating = False
   End If
   '''''''''''''''''''''''''''''''''''''''''''''''''

   DisableScreenUpdating = val
End Function

Question:

What am i missing in 2007 that 2010 is either assuming or is working correctly?

  • Still tracking down the bug cause it is still happening on 1 version of the file but other two versions it will not. The Versions all have the same code-base but based on various settings change representation to the end-user(s).

NOTE:

  • Please DO NOT focus on the "Why i am doing this", and more of what situations would cause the ScreenUpdating method to NOT be changed from True to False.

Solution

  • You could try eliminating the conditional and see if the problems is still there. That ways you'd know if it has something to do with conditional or not or 'val'.

    Function DisableScreenUpdating() As Boolean
      Application.ScreenUpdating = False
      DisableScreenUpdating = True
    End Function
    

    Assuming this makes your bug go away, I'd then focus on the call....

    DisableScreenUpdating(Application.ScreenUpdating)
    

    Perhaps the bug something to do with reading the ScreenUpdating property, followed shortly by write. That's just a guess though.

    Also, I'd search your project for any other usage of Application.ScreenUpdating. There may be some other code causing the updating to return to True.