-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAetnaFormFormulas.vb
153 lines (150 loc) · 6.05 KB
/
AetnaFormFormulas.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
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
Public Function TotalEmployeeWeeks(StartDate As String, EndDate As String)
Dim nameArray() As String
Dim countArray() As String
ReDim Preserve nameArray(100)
ReDim Preserve countArray(100)
Dim x As Integer: x = 5
Dim y As Integer: y = 0
For y = 0 To 100
nameArray(y) = ""
countArray(y) = 0
Next
y = 0
Dim i As Integer
For i = 1 To ActiveWorkbook.Worksheets.Count
If DateInside(ActiveWorkbook.Worksheets(i).Name, StartDate, EndDate) Then
x = 5
Do While ActiveWorkbook.Worksheets(i).Cells(x, 1) <> "Totals"
If ActiveWorkbook.Worksheets(i).Cells(x, 10).Value <> "" Then
For y = 0 To UBound(nameArray, 1)
If y = UBound(nameArray, 1) Then
ReDim Preserve nameArray(2 * UBound(nameArray, 1))
ReDim Preserve countArray(2 * UBound(countArray, 1))
nameArray(y) = ActiveWorkbook.Worksheets(i).Cells(x, 1)
countArray(y) = 1
Exit For
ElseIf nameArray(y) = ActiveWorkbook.Worksheets(i).Cells(x, 1) Then
countArray(y) = countArray(y) + 1
Exit For
ElseIf countArray(y) = 0 Then
nameArray(y) = ActiveWorkbook.Worksheets(i).Cells(x, 1)
countArray(y) = 1
Exit For
End If
Next
End If
x = x + 1
Loop
End If
Next
x = x + 1
Dim s As String: s = ""
For y = 0 To UBound(nameArray, 1)
s = s + nameArray(y) + ": " + CStr(countArray(y)) + vbCrLf
Next
PrintToFile (s)
End Function
Public Function TotalEmployeeDays(StartDate As String, EndDate As String)
Dim nameArray() As String
Dim countArray() As String
ReDim Preserve nameArray(100)
ReDim Preserve countArray(100)
Dim x As Integer: x = 5
Dim y As Integer: y = 0
Dim z As Integer: z = 0
Dim DayCount As Integer: DayCount = 0
For y = 0 To 100
nameArray(y) = ""
countArray(y) = 0
Next
y = 0
Dim i As Integer
For i = 1 To ActiveWorkbook.Worksheets.Count
If DateInside(ActiveWorkbook.Worksheets(i).Name, StartDate, EndDate) Then
DayCount = DayCount + 5
x = 5
Do While ActiveWorkbook.Worksheets(i).Cells(x, 1) <> "Totals"
For z = 0 To 6
If ActiveWorkbook.Worksheets(i).Cells(x, 3 + z).Value <> "" Then
For y = 0 To UBound(nameArray, 1)
If y = UBound(nameArray, 1) Then
ReDim Preserve nameArray(2 * UBound(nameArray, 1))
ReDim Preserve countArray(2 * UBound(countArray, 1))
nameArray(y) = ActiveWorkbook.Worksheets(i).Cells(x, 1)
countArray(y) = 1
Exit For
ElseIf nameArray(y) = ActiveWorkbook.Worksheets(i).Cells(x, 1) Then
countArray(y) = countArray(y) + 1
Exit For
ElseIf countArray(y) = 0 Then
nameArray(y) = ActiveWorkbook.Worksheets(i).Cells(x, 1)
countArray(y) = 1
Exit For
End If
Next
End If
Next
x = x + 1
Loop
End If
Next
x = x + 1
Dim s As String: s = "DayCount: " + CStr(DayCount) + vbCrLf
For y = 0 To UBound(nameArray, 1)
s = s + nameArray(y) + ": " + CStr(countArray(y)) + vbCrLf
Next
PrintToFile (s)
End Function
Public Function AverageNumberOfEmployees(StartDate As String, EndDate As String) As Integer
Dim nameArray() As String
Dim countArray() As Boolean
ReDim Preserve nameArray(100)
ReDim Preserve countArray(100, 12)
Dim x As Integer: x = 5
Dim y As Integer: y = 0
Dim z As Integer: z = 0
For y = 0 To 100
nameArray(y) = ""
For z = 0 To 11
countArray(y, z) = False
Next
Next
y = 0
z = 0
Dim i As Integer
For i = 1 To ActiveWorkbook.Worksheets.Count
If DateInside(ActiveWorkbook.Worksheets(i).Name, StartDate, EndDate) Then
x = 5
Do While ActiveWorkbook.Worksheets(i).Cells(x, 1) <> "Totals"
If ActiveWorkbook.Worksheets(i).Cells(x, 10).Value <> "" Then
For y = 0 To UBound(nameArray, 1)
If y = UBound(nameArray, 1) Then
ReDim Preserve nameArray(2 * UBound(nameArray, 1))
ReDim Preserve countArray(2 * UBound(countArray, 1), 12)
nameArray(y) = ActiveWorkbook.Worksheets(i).Cells(x, 1)
countArray(y, GetMonthFromDate(ActiveWorkbook.Worksheets(i).Name) - 1) = True
Exit For
ElseIf nameArray(y) = ActiveWorkbook.Worksheets(i).Cells(x, 1) Then
countArray(y, GetMonthFromDate(ActiveWorkbook.Worksheets(i).Name) - 1) = True
Exit For
ElseIf nameArray(y) = "" Then
nameArray(y) = ActiveWorkbook.Worksheets(i).Cells(x, 1)
countArray(y, GetMonthFromDate(ActiveWorkbook.Worksheets(i).Name) - 1) = True
Exit For
End If
Next
End If
x = x + 1
Loop
End If
Next
Dim total As Integer: total = 0
For y = 0 To 11
For z = 0 To UBound(nameArray, 1)
If countArray(z, y) Then
total = total + 1
End If
Next
Next
AverageNumberOfEmployees = total
End Function