When running my VBA code the sheet names flash up in duplicate at the bottom of the screen, any thoughts why.
VBA Code:
Sub Optimise(Flag As Boolean)
On Error Resume Next
F = Not Flag
Application.ScreenUpdating = F
Application.DisplayAlerts = F
Application.EnableEvents = F
Application.DisplayStatusBar = F
ActiveSheet.DisplayPageBreaks = F
If F = True Then
Application.Calculation = xlCalculationAutomatic
Else
Application.Calculation = xlCalculationManual
End If
On Error GoTo 0
End Sub
Sub Update()
'switch off updating to stop screen flickering
Optimise (True)
SheetList = Array("Leaderboard", "Entries_by_Name", "Points_by_League", "Tables", "Admin")
For Count = 0 To UBound(SheetList)
'Unprotect the sheets
Sheets(SheetList(Count)).Unprotect
'Add date and time to admin sheet
Sheets("Admin").Range("A2").Value = Now
Next
' Update - Refresh Queries
'
ActiveWorkbook.RefreshAll
DoEvents
' Sort the sheet
With ActiveWorkbook.Worksheets("Leaderboard").Sort
.SortFields.Clear
.SortFields.Add Range("P1"), , xlAscending 'Sort by Sort Help Help column P
.SortFields.Add Range("R1"), , xlDescending ' Sort by GD value
.SortFields.Add Range("D1"), , xlDescending 'Sort Total column
.SetRange Range("B1:R350")
.Header = xlYes
.Apply
End With
Sheets("Leaderboard").Select
Range("A1").Select
'Allow screen to update now
Optimise (False)
'Reprotect the modified sheets
For Count = 0 To UBound(SheetList)
'DoEvents
Do
DoEvents
Application.Calculate
Loop While Not CalculationState = xlDone
Sheets(SheetList(Count)).Protect
Next
'MsgBox "Job Done"
End Sub