-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNonEntryBulkRunner.bas
More file actions
48 lines (40 loc) · 2.03 KB
/
NonEntryBulkRunner.bas
File metadata and controls
48 lines (40 loc) · 2.03 KB
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
'--------------------------------------------------------------------
' 2. BULK RUNNER – last 12 months of “Non-Entry Hrs M-D-YY” tabs
'--------------------------------------------------------------------
Public Sub BulkProcessNonEntryLastYear()
Const MONTHS_BACK As Long = 18
Const prefix As String = "Non-Entry Hrs "
Const DELIM As String = "-"
Dim targetDate As Date: targetDate = DateAdd("m", -MONTHS_BACK, Date)
Dim ws As Worksheet, processed As Long, skipped As String
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.EnableEvents = False
For Each ws In ThisWorkbook.Worksheets
If Left(ws.name, Len(prefix)) = prefix Then
Dim datePart As String: datePart = Mid(ws.name, Len(prefix) + 1) 'e.g. "5-1-25"
Dim parts() As String: parts = Split(datePart, DELIM)
If UBound(parts) = 2 Then
Dim m As Long, d As Long, yy As Long, sheetDate As Date
m = Val(parts(0)): d = Val(parts(1)): yy = Val(parts(2))
If yy < 100 Then yy = yy + 2000
On Error Resume Next: sheetDate = DateSerial(yy, m, d): On Error GoTo 0
If sheetDate >= targetDate Then
ProcessNonEntrySheet ws, Format(sheetDate, "yyyy-mm-dd")
processed = processed + 1
Else
skipped = skipped & ws.name & " (too old)" & vbCrLf
End If
Else
skipped = skipped & ws.name & " (bad name)" & vbCrLf
End If
End If
Next ws
Application.EnableEvents = True
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
MsgBox processed & " sheet(s) processed." & _
IIf(skipped <> "", vbCrLf & "Skipped:" & vbCrLf & skipped, ""), _
vbInformation, "Non-Entry import complete"
End Sub
'====================================================================