I have a workbook that takes more than 6 seconds to open due to a number of macros that run within the workbook_open event.
I want to speed this up so I have used a timer to test different parts of the code at startup vs being run while the workbook is open. All of the parts take the same time to run in both situations, except this part:
Dim ATime As Double
Dim BTime As Double
ATime = timer
Dim b As Long
For b = 5 To 268
If Sheets("Orders").Range("F" & b) = "Locked" Then
Sheets("Orders").Range("C" & b).Locked = True
Sheets("Orders").Range("D" & b).Locked = True
Sheets("Orders").Range("E" & b).Locked = True
End If
Next
BTime = timer
MsgBox "1. " & Format(BTime - ATime, "0.00 \s\ec")
When run at workbook_open: 2.78 seconds. When run manually within workbook: 0.01 seconds.
What is the problem here?