forked from aaronkeene/ExcelVBA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SpeedUp.vb
77 lines (59 loc) · 2.08 KB
/
SpeedUp.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
Sub SpeedUp(Optional DoIt As Boolean = True)
'This macro will set most properties for speeding up macro execution.
' Before running your macros, you put 'SpeedUp' as one of the first
' commands in your code, and, as one of the last lines in your code,
' you put 'SpeedUp (False)' to reset the properties.
'Retrieved from www.excelguard.dk
'Initialize
With Application
.Cursor = xlWait
.DisplayStatusBar = True
.WindowState = xlMaximized
'.VBE.MainWindow.Visible = False
.EnableEvents = False
.DisplayAlerts = False
.ScreenUpdating = False
.Calculation = xlCalculationManual
' .Interactive = False
.AskToUpdateLinks = False
.IgnoreRemoteRequests = False
If ThisWorkbook.IsAddin Then .EnableCancelKey = xlDisabled
End With
On Error Resume Next
'Define variables
Dim WS As Worksheet
Dim WB As Workbook
Set WB = ActiveWorkbook
'Don't display pagebreaks
ActiveSheet.DisplayPageBreaks = False
ActiveSheet.DisplayAutomaticPageBreaks = False
For Each WS In WB.Worksheets
WS.DisplayPageBreaks = False
WS.DisplayAutomaticPageBreaks = False
Next
'Set workbook properties
With WB
.AcceptAllChanges
.SaveLinkValues = False
.UpdateRemoteReferences = True
.UpdateLinks = xlUpdateLinksAlways
.ConflictResolution = xlUserResolution
.Colors(14) = RGB(0, 153, 153)
End With
'Skip to speedup
Set WB = Nothing
Set WS = Nothing
If DoIt = True Then Exit Sub
ES: ' End of Sub
With Application
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
.DisplayAlerts = True
.EnableEvents = True
.EnableCancelKey = xlInterrupt
.CutCopyMode = False
.Interactive = True
.Cursor = xlDefault
.StatusBar = False
End With
End Sub