Application.ScreenUpdating = False issues

Afro_Cookie

Board Regular
Joined
Mar 17, 2020
Messages
103
Office Version
  1. 365
Platform
  1. Windows
Found this post, ScreenUpdating = False not working, that is having a similar issue to mine. From what I've read this is a common issue with Excel after an update Microsoft did.

Below is my code and I cannot figure out how to keep ScreenUpdating set to false. It's not a major issue but the continual flickering of the screen is really annoying, especially when other workbooks are open as well.

Any help would be appreciated.

VBA Code:
Sub SaveThis()

Application.ScreenUpdating = False
Application.DisplayAlerts = False
ThisWorkbook.Save
Application.DisplayAlerts = True

NextTime = Now + TimeValue("00:00:10")
Application.OnTime NextTime, "SaveThis"

End Sub

Sub SaveThisEnd()
    On Error Resume Next
    Application.ScreenUpdating = False
    Application.OnTime NextTime, "SaveThis", Schedule:=False
End Sub
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Try to only one ScreenUpdating = False, something like this:
Start with the StartSave macro

VBA Code:
Sub StartSave()
  Application.ScreenUpdating = False
  Call SaveThis
End Sub

Sub SaveThis()
  Application.DisplayAlerts = False
  ThisWorkbook.Save
  Application.DisplayAlerts = True
  NextTime = Now + TimeValue("00:00:10")
  Application.OnTime NextTime, "SaveThis"
End Sub

Sub SaveThisEnd()
  On Error Resume Next
  Application.ScreenUpdating = False
  Application.OnTime NextTime, "SaveThis", Schedule:=False
End Sub
 
Upvote 0
The End Sub is the issue! When a procedure ends, Screenupdating is reset.
You might try Application.Visible=false at the beginning and =True at the end. But whatever is in the background will show.
 
Upvote 0
Thanks for this suggestion, I did try it but the extra sub did not affect it at all.

Try to only one ScreenUpdating = False, something like this:
Start with the StartSave macro

VBA Code:
Sub StartSave()
  Application.ScreenUpdating = False
  Call SaveThis
End Sub

Sub SaveThis()
  Application.DisplayAlerts = False
  ThisWorkbook.Save
  Application.DisplayAlerts = True
  NextTime = Now + TimeValue("00:00:10")
  Application.OnTime NextTime, "SaveThis"
End Sub

Sub SaveThisEnd()
  On Error Resume Next
  Application.ScreenUpdating = False
  Application.OnTime NextTime, "SaveThis", Schedule:=False
End Sub
 
Upvote 0
If the end sub is the issue, how do we work around when it's a required part of the sub?

I also tried your code. It did not work the way I had hoped though. As you mentioned it did show what was in the background which is as cumbersome as the flickering screen during the update.
The End Sub is the issue! When a procedure ends, Screenupdating is reset.
You might try Application.Visible=false at the beginning and =True at the end. But whatever is in the background will show.
 
Upvote 0
Every time it saves, the screen refreshes and flickers or flashes from my current workbook to the workbook with the macro. I've tried setting the screen updating to false, but it does not work. I've read this is a common issue with 2013 and 2016 versions.

What is it that is making the screen flicker ?
 
Upvote 0
"flashes from my current workbook to the workbook with the macro " what does that mean ?

And which part of the screen does it flash ? Is it the entire excel screen (including the ribbon section) or just the worksheet area ?
 
Upvote 0
My save macro is in WB1, I am working in WB2. Every time WB1 saves, it flashes/flickers (Entire screen) from WB2 to WB1. Once save is completed it goes back to WB2.

"flashes from my current workbook to the workbook with the macro " what does that mean ?

And which part of the screen does it flash ? Is it the entire excel screen (including the ribbon section) or just the worksheet area ?
 
Upvote 0
Ok- I see what you mean .

This is due to the Single Document Interface (SDI) that came with excel 2013 . It can be annoying and counter-intuitive when you are working on a different workbook and then all of a sudden you are taken to the workbook that is running the save code.

Here is a custom Property that I named (EnableSDIWindowActivation) which if you set it to FALSE before saving will solve the issue :

Your code now becomes :
VBA Code:
Option Explicit

#If VBA7 Then
    Declare PtrSafe Function SetWindowPos Lib "user32" (ByVal hwnd As LongPtr, ByVal hWndInsertAfter As LongPtr, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
    Declare PtrSafe Function GetActiveWindow Lib "user32" () As LongPtr
#Else
    Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
    Declare Function GetActiveWindow Lib "user32" () As Long
#End If


Dim NextTime As Double


Sub SaveThis()

    EnableSDIWindowActivation = False
        ThisWorkbook.Save
    EnableSDIWindowActivation = True
    
    NextTime = Now + TimeValue("00:00:10")
    Application.OnTime NextTime, "SaveThis"

End Sub

Sub SaveThisEnd()
    On Error Resume Next
    Application.OnTime NextTime, "SaveThis", Schedule:=False
End Sub



Public Property Let EnableSDIWindowActivation(ByVal Enable As Boolean)

    Const HWND_TOPMOST = -1
    Const HWND_NOTOPMOST = -2
    Const SWP_NOSIZE = &H1
    Const SWP_NOMOVE = &H2
    Const SWP_NOACTIVATE = &H10

    If Not ActiveWorkbook Is ThisWorkbook Then
        If Enable Then
            SetWindowPos GetActiveWindow, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE Or SWP_NOMOVE Or SWP_NOSIZE
        Else
            SetWindowPos GetActiveWindow, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE Or SWP_NOMOVE Or SWP_NOSIZE
        End If
    End If

End Property
 
Upvote 0

Forum statistics

Threads
1,223,723
Messages
6,174,122
Members
452,545
Latest member
boybenqn

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top