-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.bas
362 lines (247 loc) · 8.12 KB
/
Main.bas
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
Attribute VB_Name = "Main"
Private Sub Workbook_Open()
Application.OnKey "{F1}", ""
ActiveWindow.Close
End Sub
Sub centerOverColumn()
Attribute centerOverColumn.VB_ProcData.VB_Invoke_Func = "J\n14"
Selection.HorizontalAlignment = xlCenterAcrossSelection
End Sub
Sub generalAlignment()
Attribute generalAlignment.VB_ProcData.VB_Invoke_Func = "K\n14"
Selection.HorizontalAlignment = xlGeneral
End Sub
Sub snapShot()
Attribute snapShot.VB_ProcData.VB_Invoke_Func = "S\n14"
'
' setupChecks Macro
' Adds rows and columns up and pastes values, then checks to see if anything has changed after modification. Used for tech review purposes.
Application.Calculation = xlCalculationManual
'Sets a cell equal to everything in print range
Range("Xba2").Select
ActiveCell.FormulaR1C1 = "=RC[-16276]"
Range("Xba2").Copy
Range("Xba2:XFD1000").Select
ActiveSheet.Paste
ActiveSheet.Calculate
Selection.Copy
'Pastes values of everything in print range and checks to see if two are equivalent.
Range("Xba1002").Select
Selection.PasteSpecial Paste:=xlPasteValues
Range("Xba2002").Select
ActiveCell.FormulaR1C1 = "=R[-1000]C=R[-2000]C"
Range("Xba2002").Copy
Range("Xba2002:Xfd3000").Select
ActiveSheet.Paste
'Counts the number of true and false values and checks to see if these change.
Range("xk1").Select
ActiveCell.FormulaR1C1 = "=COUNTIF(R[1]:R[99999],TRUE)"
ActiveSheet.Calculate
Selection.Copy
Range("xm1").Select
Selection.PasteSpecial Paste:=xlPasteValues
Range("xl1").Select
ActiveCell.FormulaR1C1 = "=COUNTIF(R[1]:R[99999],FALSE)"
Calculate
Selection.Copy
Range("xn1").Select
Selection.PasteSpecial Paste:=xlPasteValues
Range("F1").Select
ActiveCell.FormulaR1C1 = "=AND(RC[629]=RC[631],RC[630]=RC[632])"
Range("R1").Select
ActiveCell.FormulaR1C1 = "=RC[-12]"
Range("ad1").Select
ActiveCell.FormulaR1C1 = "=RC[-12]"
Range("ap1").Select
ActiveCell.FormulaR1C1 = "=RC[-12]"
Range("bb1").Select
ActiveCell.FormulaR1C1 = "=RC[-12]"
'Makes the cell easier to read
Range("f1,r1,ad1,ap1,bb1").Select
Selection.Font.Size = 20
Selection.Font.Color = -16776961
Selection.Interior.Color = 65535
Selection.Font.Bold = True
Selection.Columns.AutoFit
Selection.Rows.AutoFit
Range("a1").Select
Application.Calculation = xlCalculationAutomatic
End Sub
Sub snapShotReset()
Attribute snapShotReset.VB_ProcData.VB_Invoke_Func = "Z\n14"
'Should only be used after snapShot sub has been used.
'This is used to re-paste the values off the the side so that check is back to true.
Range("Xba2:XFD1000").Copy
Range("Xba1002").PasteSpecial Paste:=xlPasteValues
'Puts the active cell back to the beginning of sheet
Range("A1").Select
End Sub
Sub RefreshZoom()
Attribute RefreshZoom.VB_ProcData.VB_Invoke_Func = "A\n14"
Dim ws As Worksheet
Dim targetZoom As Integer
targetZoom = InputBox(Prompt:="Target Zoom:", _
Title:="Target Zoom", Default:="Enter Desired Zoom")
Application.Calculation = xlCalculationManual
For Each ws In Worksheets
If ws.Visible = xlSheetHidden Or ws.Visible = xlVeryHidden Then GoTo Line2
ws.Select
ActiveWindow.View = xlNormalView
ActiveWindow.Zoom = targetZoom
ws.Range("a1").Activate
Line2: Next ws
ActiveWorkbook.Worksheets(1).Activate
Application.Calculation = xlCalculationAutomatic
End Sub
Sub FitComments()
Attribute FitComments.VB_ProcData.VB_Invoke_Func = "V\n14"
Dim xComment As Comment
For Each xComment In Application.ActiveSheet.Comments
xComment.Shape.TextFrame.AutoSize = True
Next
End Sub
Sub blackAndWhite()
Dim sheet As Worksheet
For Each sheet In Worksheets
sheet.PageSetup.blackAndWhite = True
Next sheet
End Sub
Sub autoFitColumns()
Attribute autoFitColumns.VB_ProcData.VB_Invoke_Func = "C\n14"
Selection.Columns.AutoFit
End Sub
Sub BlueFont()
Attribute BlueFont.VB_ProcData.VB_Invoke_Func = "B\n14"
With Selection.Font
.Color = -65536
.TintAndShade = 0
End With
End Sub
Sub RedFont()
Attribute RedFont.VB_ProcData.VB_Invoke_Func = "E\n14"
With Selection.Font
.Color = -16776961
.TintAndShade = 0
End With
End Sub
Sub PinkFont()
Attribute PinkFont.VB_ProcData.VB_Invoke_Func = "P\n14"
With Selection.Font
.Color = -65281
.TintAndShade = 0
End With
End Sub
Sub NumberFormat()
Attribute NumberFormat.VB_ProcData.VB_Invoke_Func = "N\n14"
With Selection
.NumberFormat = "#,##0_);[Red](#,##0)"
End With
End Sub
Sub DollarFormat()
Attribute DollarFormat.VB_ProcData.VB_Invoke_Func = "D\n14"
With Selection
.NumberFormat = "$#,##0_);[Red]($#,##0)"
End With
End Sub
Sub FDXChgLinks()
Dim cell As Range
Dim rng As Range
Dim old_link As String
Dim new_link As String
Dim wb As Workbook
Dim linkwb As Workbook
'Application.AskToUpdateLinks = False
Set wb = ActiveWorkbook
Set rng = Range("links_rng")
For Each cell In rng
If cell.Value = "UPDATED" Then GoTo Line2
old_link = cell.Offset(, 2).Text
new_link = cell.Offset(, 3).Text
On Error GoTo Line2
Workbooks.Open Filename:=new_link, UpdateLinks:=False
wb.Activate
ActiveWorkbook.ChangeLink Name:=old_link, NewName:=new_link, Type:=xlExcelLinks
cell.Value = "UPDATED"
Set linkwb = Workbooks.Open(new_link)
With linkwb
.Close SaveChanges:=False
End With
Set linkwb = Nothing
'linkwb.Activate
'ActiveWorkbook.Close SaveChanges:=False
'Application.ActiveWindow.Close SaveChanges:=False
'Application.Quit
'Windows(new_link).Activate
'ActiveWorkbook.Close SaveChanges:=False
wb.Activate
Line2: Next cell
End Sub
Sub Comments()
Dim cel As Range
Dim com As String
Dim selRng As Range
Set selRng = Application.Selection
For Each cell In selRng.Cells
With cell
.ClearComments
End With
If cell.Value <> "" Then
With cell.AddComment(cell.Text)
With .Shape.TextFrame
With .Characters(1, 13).Font
.Bold = True
End With
End With
End With
End If
Next
Call FitComments
End Sub
Sub SetGlobalPrintArea()
Dim xWs As Worksheet
Dim WorkRng As Range
Set WorkRng = Application.Selection
For Each xWs In Application.ActiveWindow.SelectedSheets
xWs.PageSetup.PrintArea = WorkRng.Address
Next
End Sub
Sub ShowAllNames()
Dim n As Name
For Each n In ActiveWorkbook.Names
n.Visible = True
Next n
End Sub
Sub GoToSheets()
Attribute GoToSheets.VB_ProcData.VB_Invoke_Func = "G\n14"
Application.CommandBars("workbook tabs").ShowPopup
End Sub
Sub FormatData()
' Keyboard Shortcut:
Dim ws As Worksheet
Dim rng As Range
Dim numSheets As Integer
numSheets = ActiveWorkbook.Worksheets.Count
For Each ws In Worksheets
If ws.CodeName = "Sheet" & numSheets Then GoTo Line1
ws.Select
Columns("X:IV").Clear
If ActiveSheet.AutoFilterMode Then Cells.AutoFilter
Cells.Select
Selection.NumberFormat = "General"
Set rng = Range(Range("B2:Z2").Find("DOI").Offset(1), Range("B2:Z2").Find("DOI").Offset(1).End(xlDown))
rng.NumberFormat = "m/d/yyyy"
Set rng = Range(Range("B2:Z2").Find("Added Date").Offset(1), Range("B2:Z2").Find("Added Date").Offset(1).End(xlDown))
rng.NumberFormat = "m/d/yyyy"
Set rng = Range(Range("B2:Z2").Find("Last Status Date").Offset(1), Range("B2:Z2").Find("Last Status Date").Offset(1).End(xlDown))
rng.NumberFormat = "m/d/yyyy"
Set rng = Range(Range("B2:Z2").Find("Indemnity Paid").Offset(1), Range("B2:Z2").Find("Indemnity Outstanding").Offset(1).End(xlDown))
rng.NumberFormat = "#,##0_);[Red](#,##0)"
Set rng = Range(Range("B2:Z2").Find("Medical Incurred").Offset(1), Range("B2:Z2").Find("Total Incurred").Offset(1).End(xlDown))
rng.NumberFormat = "#,##0_);[Red](#,##0)"
Set rng = Range(Range("B2:Z2").Find("GM").Offset(1), Range("B2:Z2").Find("GM").Offset(1).End(xlDown))
rng.NumberFormat = "#,##0_);[Red](#,##0)"
Columns("X:IV").Select
Selection.Clear
Range("A1").Select
Line1: Next ws
End Sub