how to stop screen flicker when looping through worksheets

Hello,

Is there a way to eliminate screen flicker when looping through the worksheets in a workbook. I wrote the following code to loop through the worksheets in a workbook and set the columns of worksheets.  However, the client is complaining that the flicker is bothering his eyes.  Go figure.

Public Sub SetColumns(strType As String)
    ' Comments:
    ' Params  :
    ' Created : 08/05/13 11:50 JV
    ' Modified:
    
    On Error GoTo PROC_ERR
    Dim wb As Workbook
    Dim ws As Worksheet
    Dim cell As Range
    
    Set wb = ThisWorkbook
    
    For Each ws In wb.Worksheets
        If Left(ws.Name, 3) = "WTS" Then
            ws.Unprotect
            If strType = "Construction" Then
                For Each cell In ws.Range("HoursWorked").Cells
                    Application.EnableEvents = False
                    cell.Locked = False
                    Application.EnableEvents = True
                Next
                For Each cell In ws.Range("WorkOrder").Cells
                    Application.EnableEvents = False
                    cell.value = ""
                    Application.EnableEvents = True
                Next
                For Each cell In ws.Range("TimeIn").Cells
                    Application.EnableEvents = False
                    cell.value = ""
                    Application.EnableEvents = True
                Next
                For Each cell In ws.Range("TimeOut").Cells
                    Application.EnableEvents = False
                    cell.value = ""
                    Application.EnableEvents = True
                Next
                
                ws.Range("C:F").EntireColumn.Hidden = True
            ElseIf strType = "Service" Then
                ws.Range("HoursWorked").Locked = False
                ws.Range("C:C").EntireColumn.Hidden = False
            End If
            ws.Protect
        End If
    Next
    
PROC_EXIT:
    Application.EnableEvents = True
    Exit Sub
    
PROC_ERR:
    MsgBox Err.Description, vbCritical, "basExcelUtilities.SetColumns"
    Resume PROC_EXIT
    
End Sub

Open in new window

Juan VelasquezAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nutschCommented:
start your code with
application.screenupdating=false

end it with
application.screenupdating=true

It should do it

Thomas
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
nutschCommented:
another point, you don't really need to loop the cells in your code, you can very well run directly

ws.Range("TimeIn").value = ""

or

ws.Range("HoursWorked").locked = False
0
Juan VelasquezAuthor Commented:
I did use application.screenupdating =false but it didn't seem to make much difference until I put it in the right location.   Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.