Hi guys so this part of my code is causing a little bit of flickering so i figure i must be doing something wrong, at first i thought just the act of hiding and unhiding columnns was causing the flicker and its just unavoidable but some sheet changes dont require column change and it still flickers.
I should note there is no flickering when i remove this portion of the code so it absolutely it is this code that is the problem.
Also i'm very new to coding so if someone wouldnt mind optimizing my code and kindly explaining what you did and why i would really appreciate it.
Thanks :)
Private Sub Worksheet_Change(ByVal Target As Range)
   If Sheets("Calendar").Range("B5") = "Hours" Then
        Application.ScreenUpdating = False
        Call UnlockSheet
        On Error GoTo BlankStaff
        Sheets("Calendar").Range("AU:AW").EntireColumn.Hidden = False
    With Worksheets("Calendar").Range("AV2:AV8").Borders(xlEdgeRight)
        .LineStyle = xlLineStyleNone
    End With
    With Worksheets("Calendar").Range("AV3:AV8").Borders(xlEdgeRight)
        .LineStyle = xlDashDotDot
    End With
        Call LockSheet
        Application.ScreenUpdating = True
    Else
        If Sheets("Calendar").Range("B5") = "Days" And Sheets("Calendar").Range("AV4").Value = "No" And Sheets("Calendar").Range("AV5").Value = "No" And Sheets("Calendar").Range("AV6").Value = "No" And Sheets("Calendar").Range("AV7").Value = "No" And Sheets("Calendar").Range("AV8").Value = "No" Then
            Application.ScreenUpdating = False
            Call UnlockSheet
            On Error GoTo BlankStaff
            Sheets("Calendar").Range("AU:AW").EntireColumn.Hidden = True
        With Worksheets("Calendar").Range("AV2:AV8").Borders(xlEdgeRight)
            .LineStyle = xlContinuous
            .Weight = xlThin
            .ColorIndex = 1
        End With
            Call LockSheet
            Application.ScreenUpdating = True
        Else
            Application.ScreenUpdating = False
            Call UnlockSheet
            Sheets("Calendar").Range("AU:AV").EntireColumn.Hidden = False
            Sheets("Calendar").Range("AW:AW").EntireColumn.Hidden = True
        With Worksheets("Calendar").Range("AV2:AV8").Borders(xlEdgeRight)
            .LineStyle = xlContinuous
            .Weight = xlThin
            .ColorIndex = 1
        End With
            Call LockSheet
            Application.ScreenUpdating = True
        End If
    End If
BlankStaff:
    Exit Sub
End Sub
 
     
     
     
    