Excel ScreenUpdating False and still flickering screen
excel, vba
Solution
Use `WindowState` in combination with `DisplayAlerts`. The user won't see the window minimize, but it will also keep Excel from flickering during a `SaveAs`, changing window visibility, or changing workbook/worksheet protection.
Dim iWindowState as Integer
With Application
.ScreenUpdating = False
.DisplayAlerts = False
iWindowState = .WindowState
.WindowState = xlMinimized
End With
'Flickery code
With Application
.ScreenUpdating = True
.DisplayAlerts = True
.WindowState = iWindowState
End With
Problem
I have the following simple code to close a range of open workbooks. I have just switched to Excel 2013 and in this new version my screen keeps flashing a white window in Excel for each workbook that is unhidden. How can I get that annoying screen flicker to shut off? ``` Sub CloseFiles() On Error Resume Next Application.ScreenUpdating = False Application.StatusBar = "Please wait while files are closed." Application.DisplayAlerts = False Dim rCell As Range For Each rCell In Range("Files") Application.StatusBar = "Closing file " & rCell.Value If rCell.Value <> "" Then Windows(rCell.Value).Visible = True Workbooks(rCell.Value).Close SaveChanges:=True End If Next rCell Application.WindowState = xlMaximized Windows("Filename.xlsm").Activate Application.DisplayAlerts = True Application.StatusBar = False Application.ScreenUpdating = True End Sub ```