-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModule2.bas
More file actions
executable file
·1229 lines (976 loc) · 47.6 KB
/
Module2.bas
File metadata and controls
executable file
·1229 lines (976 loc) · 47.6 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
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
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Attribute VB_Name = "Module2"
Option Explicit
Sub PushToMasterTrackerSP()
Dim wb As Workbook
Dim MasterTracker As Workbook
Dim lastLocalRow As Integer
Dim lastLogRow As Integer
Dim localRow As Integer
Dim logCount As Integer: logCount = 0
Dim row As Integer
Dim currentWR As String
Dim redValue As Integer: redValue = 0
Dim greenValue As Integer: greenValue = 0
Dim blueValue As Integer: blueValue = 0
Dim colorValue As String
Dim foundOnSheet As Boolean: foundOnSheet = False
Dim username As String
Dim password As String
Dim usingSharePoint As Boolean: usingSharePoint = False
Dim currentMonth As String
Dim deliverableResponse As Boolean: deliverableResponse = False
Dim wsName As String: wsName = "Main"
Dim ws2Name As String: ws2Name = "Tables"
Dim wSheet As Variant
Dim rgFound As Range
Dim stringArray As Variant
Dim progRow As Integer: progRow = 1
Dim i As Integer
' Returning username and password by reference
If Not GetUsernameAndPassword(username, password, wsName) Then Exit Sub
Application.StatusBar = "Pushing WR info to SharePoint"
With ThisWorkbook.Worksheets(wsName)
lastLocalRow = .Cells(.Rows.Count, "A").End(xlUp).row
' Cleaning right side
.Range("M8:O" & lastLocalRow).ClearContents
.Range("M8:O" & lastLocalRow).Interior.ColorIndex = 0
End With
' Exiting program if there are no WRs to push
If lastLocalRow = 7 Then
MsgBox "No info to push"
Application.StatusBar = ""
Exit Sub
End If
' Function to check overrides
Set MasterTracker = OverrideHandler(usingSharePoint, wsName)
If MasterTracker Is Nothing Then
Exit Sub
End If
On Error GoTo 0
' Looping to find checked out master tracker
For Each wb In Application.Workbooks
If InStr(wb.Worksheets(1).Name, "Project Pipeline") > 0 Then
Set MasterTracker = wb
Exit For
End If
Next
' Finding last row on main tab of tool - TWICE?
With ThisWorkbook.Worksheets(wsName)
lastLocalRow = .Cells(.Rows.Count, "A").End(xlUp).row
End With
' Removing previous intake cell color fills
With ThisWorkbook.Worksheets("Log")
lastLogRow = .Cells(.Rows.Count, "H").End(xlUp).row
colorValue = .Range("H" & lastLogRow).Value
GetColorValues redValue, greenValue, blueValue, colorValue, wsName
End With
RemovePreviousColorsAndFilters MasterTracker, redValue, greenValue, blueValue
' Setting new desired values
With ThisWorkbook.Worksheets(wsName)
colorValue = .ComboBoxColors.Value
GetColorValues redValue, greenValue, blueValue, colorValue, wsName
End With
' Checking for Dupes, creating temp tab
ThisWorkbook.Sheets.Add.Name = "Temp"
With ThisWorkbook.Worksheets("Temp")
.Activate
stringArray = Array("Please Wait. Checking for Dupes.", _
"Please Wait. Checking Intake Blanks Tab.", _
"Please Wait. Checking Intake No's Tab.", _
"Please Wait. Checking Not Testing Tab.", _
"Please Wait. Checking TBD Tab.")
For i = LBound(stringArray) To UBound(stringArray)
.Range("A" & progRow).ColumnWidth = 16
.Range("K" & progRow).ColumnWidth = 15
.Range("A" & progRow).Value = stringArray(i)
.Range("K" & progRow).Value = "Finished"
.Range("A" & progRow).HorizontalAlignment = xlCenter
.Range("A" & progRow).VerticalAlignment = xlCenter
.Range("K" & progRow).HorizontalAlignment = xlCenter
.Range("K" & progRow).VerticalAlignment = xlCenter
.Range("A" & progRow & ":K" & progRow).Borders.LineStyle = xlContinuous
.Range("A" & progRow).WrapText = True
.Rows(progRow).RowHeight = 60
progRow = progRow + 2
Next
End With
' Iterating through WRs to check each one against Master Tracker
' Changed WS to 2 from 1 for all below
Application.ScreenUpdating = False
Application.StatusBar = "Checking for dupes against master tracker"
With ThisWorkbook.Worksheets(wsName)
For row = 8 To lastLocalRow
' Setup
currentWR = Trim(CStr(.Range("A" & row).Value))
' Updating progress green bar
CheckProgress lastLocalRow, row, "1", "none"
' Looping thru sheets
For Each wSheet In MasterTracker.Worksheets
With wSheet.UsedRange
Set rgFound = .Cells.Find(What:=currentWR, After:=.Range("A1"), LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False) ' .Activate
End With
If rgFound Is Nothing And Len(Trim(CStr(.Range("N" & row).Value))) = 0 Then
.Range("M" & row).Value = "Not on tracker"
.Range("M" & row).Interior.Color = RGB(255, 150, 150)
ElseIf Not (rgFound Is Nothing) And Len(Trim(CStr(.Range("N" & row).Value))) = 0 Then
.Range("N" & row).NumberFormat = "@"
.Range("M" & row).Value = "On Tracker"
.Range("N" & row).Value = rgFound.Worksheet.Name
.Range("M" & row).Interior.ColorIndex = 0
Exit For
ElseIf Not (rgFound Is Nothing) Then
.Range("N" & row).Value = .Range("N" & row).Value & vbCrLf & rgFound.Worksheet.Name
End If
Next
.Range("N" & row).HorizontalAlignment = xlLeft
Next row
End With
Application.ScreenUpdating = True
Application.StatusBar = "Distributing Work Requests"
ThisWorkbook.Worksheets(wsName).Activate
' Distributing WRs
With ThisWorkbook.Worksheets(wsName)
For localRow = 8 To lastLocalRow
If .Range("M" & localRow).Value = "Not on tracker" Then
If Trim(CStr(.Range("J" & localRow).Value)) <> "In_Progress" And Trim(CStr(.Range("J" & localRow).Value)) <> "System_Route_Work" Then
If Trim(CStr(.Range("J" & localRow).Value)) <> "Withdrawn" And Trim(CStr(.Range("J" & localRow).Value)) <> "Closed" Then
If Len(Trim(CStr(.Range("B" & localRow).Value))) > 0 Then
If Trim(CStr(.Range("B" & localRow).Value)) = "Yes" Then
' Add to month tabs
MonthAdder localRow, MasterTracker, redValue, greenValue, blueValue, "Tool", wsName
Else ' UAT = No
' Add to Intake No's
IntakeBlankOrNoAdder localRow, MasterTracker, "Intake No's", "Tool", wsName
End If ' End of UAT Yes/No
Else ' UAT is blank
' Add to Intake Blanks
IntakeBlankOrNoAdder localRow, MasterTracker, "Intake Blanks", "Tool", wsName
End If ' End of Empty UAT Inv
Else ' = Withdrawn
' Add to Intake No's
IntakeBlankOrNoAdder localRow, MasterTracker, "Intake No's", "Tool", wsName
End If
Else ' = In_Progress
' Push In Progress to Blanks Tab
IntakeBlankOrNoAdder localRow, MasterTracker, "Intake Blanks", "Tool", wsName
End If ' End of In Progress
End If ' End of Not on Tracker, Else do nothing
Next ' End of Main For iterating through rows
End With
' Resetting screen
Application.StatusBar = "Scrubbing Master Tracker"
ThisWorkbook.Worksheets("Temp").Activate
Application.ScreenUpdating = True
' Re-checking WRs on tabs
With ThisWorkbook.Worksheets(wsName)
' Iterate over Intake Blanks here
Application.StatusBar = "Scrubbing Intake Blanks tab"
IntakeBlanksAndNosChecker MasterTracker, username, password, redValue, greenValue, blueValue, "Intake Blanks", wsName, ws2Name
Application.Wait Now + TimeValue("00:00:01")
ThisWorkbook.Worksheets("Temp").Activate
' Iterate over Intake Nos here
Application.StatusBar = "Scrubbing Intake No's tab"
IntakeBlanksAndNosChecker MasterTracker, username, password, redValue, greenValue, blueValue, "Intake No's", wsName, ws2Name
Application.Wait Now + TimeValue("00:00:01")
ThisWorkbook.Worksheets("Temp").Activate
' Iterate over Not Testing here
Application.StatusBar = "Scrubbing Not Testing tab"
NotTestingChecker MasterTracker, username, password, wsName, ws2Name
Application.Wait Now + TimeValue("00:00:01")
ThisWorkbook.Worksheets("Temp").Activate
' Iterate over TBD tab here
Application.StatusBar = "Scrubbing TBD tab"
TBDChecker MasterTracker, username, password, wsName, ws2Name
Application.Wait Now + TimeValue("00:00:01")
ThisWorkbook.Worksheets("Temp").Activate
End With
' Cleaning up temp sheet
Application.DisplayAlerts = False
ThisWorkbook.Sheets("Temp").Delete
Application.DisplayAlerts = True
' ' Calling function to update deliverable dates on current month tab here
' deliverableResponse = UpdateDeliverableDates(MasterTracker, username, password)
'
' If deliverableResponse = False Then
' ThisWorkbook.Worksheets("Main").Range("F2").Activate
' Application.StatusBar = ""
' ThisWorkbook.Worksheets(1).Range("A1:H1").Interior.ColorIndex = 0
' If usingSharePoint = True Then
' If MasterTracker.CanCheckIn = True Then
' MasterTracker.CheckIn SaveChanges:=False
' End If
' End If
' MsgBox "Unable to connect to database with entered credentials."
' Exit Sub
' End If
' Cleanup
With ThisWorkbook.Worksheets(wsName)
' Checking workbook back in
Application.StatusBar = ""
.Activate
If usingSharePoint = True Then
If MasterTracker.CanCheckIn = True Then
'MasterTracker.CheckIn
MsgBox "Master Tracker has been checked in."
Else
MsgBox "This file cannot be checked in at this time. Please try again later."
End If
Else
MsgBox "Information has been pushed!"
End If
' Recoloring green bar on top of sheet
.Range("A1:H1").Interior.ColorIndex = 0
' Call function to generate email to Mani & Dan
FinalEmailGenerator CStr(colorValue)
' update log
If .ComboBoxLog.Value = "On" Then
For row = 8 To lastLocalRow
If .Range("M" & row).Value = "Not on tracker" Then
logCount = logCount + 1
End If
Next
With ThisWorkbook.Worksheets("Log")
lastLogRow = .Cells(.Rows.Count, "E").End(xlUp).row + 1
.Range("E" & lastLogRow).Value = Date
.Range("E" & lastLogRow).NumberFormat = "m/d/yyyy"
.Range("F" & lastLogRow).Value = ThisWorkbook.Worksheets(1).Range("E8").Value
.Range("G" & lastLogRow).Value = logCount
.Range("H" & lastLogRow).Value = colorValue
End With
End If
End With
Exit Sub
' Error handler for DB2 connection
ConnectionHandler:
ThisWorkbook.Worksheets(wsName).Range("F2").Activate
MsgBox "Unable to connect to database. Please make sure credentials are correct!"
Exit Sub
End Sub
Sub CheckProgress(lastLocalRow As Integer, row As Integer, checkRow As String, quitInd As String)
If quitInd = "start" Then
If row > (lastLocalRow / 2) Then
Exit Sub
End If
ElseIf quitInd = "end" Then
If row < (lastLocalRow / 2) Then
Exit Sub
End If
End If
' Checking status
With ThisWorkbook.Worksheets("Temp")
If Round((row - 8) / (lastLocalRow - 7), 2) * 100 >= 10 And Round((row - 8) / (lastLocalRow - 7), 2) * 100 < 20 Then
MakeGreen "B" & checkRow
ElseIf Round((row - 8) / (lastLocalRow - 7), 2) * 100 >= 20 And Round((row - 8) / (lastLocalRow - 7), 2) * 100 < 30 Then
MakeGreen "C" & checkRow
ElseIf Round((row - 8) / (lastLocalRow - 7), 2) * 100 >= 30 And Round((row - 8) / (lastLocalRow - 7), 2) * 100 < 40 Then
MakeGreen "D" & checkRow
ElseIf Round((row - 8) / (lastLocalRow - 7), 2) * 100 >= 40 And Round((row - 8) / (lastLocalRow - 7), 2) * 100 < 50 Then
MakeGreen "E" & checkRow
ElseIf Round((row - 8) / (lastLocalRow - 7), 2) * 100 >= 50 And Round((row - 8) / (lastLocalRow - 7), 2) * 100 < 60 Then
MakeGreen "F" & checkRow
ElseIf Round((row - 8) / (lastLocalRow - 7), 2) * 100 >= 60 And Round((row - 8) / (lastLocalRow - 7), 2) * 100 < 70 Then
MakeGreen "G" & checkRow
ElseIf Round((row - 8) / (lastLocalRow - 7), 2) * 100 >= 70 And Round((row - 8) / (lastLocalRow - 7), 2) * 100 < 80 Then
MakeGreen "H" & checkRow
ElseIf Round((row - 8) / (lastLocalRow - 7), 2) * 100 >= 80 And Round((row - 8) / (lastLocalRow - 7), 2) * 100 < 90 Then
MakeGreen "I" & checkRow
ElseIf Round((row - 8) / (lastLocalRow - 7), 2) * 100 >= 90 And Round((row - 8) / (lastLocalRow - 7), 2) * 100 < 100 Then
MakeGreen "J" & checkRow
End If
End With
End Sub
Sub MakeGreen(rangeString As String)
With ThisWorkbook.Worksheets("Temp")
' removed screenupdating lines
.Range(rangeString).Interior.Color = RGB(0, 200, 0)
End With
End Sub
Sub GetColorValues(ByRef redValue As Integer, ByRef greenValue As Integer, ByRef blueValue As Integer, colorValue As String, wsName As String)
Select Case colorValue
Case "Yellow"
redValue = 255
greenValue = 255
blueValue = 0
Case "Blue"
redValue = 0
greenValue = 125
blueValue = 255
Case "Cyan/Light Blue"
redValue = 0
greenValue = 255
blueValue = 255
Case "Light Green"
redValue = 145
greenValue = 255
blueValue = 0
Case "Pink"
redValue = 255
greenValue = 0
blueValue = 255
Case "Orange"
redValue = 255
greenValue = 125
blueValue = 0
Case "Purple"
redValue = 125
greenValue = 0
blueValue = 255
Case Else
redValue = 255
greenValue = 255
blueValue = 0
End Select
End Sub
Public Function GetUsernameAndPassword(ByRef username As String, ByRef password As String, wsName As String) As Boolean
GetUsernameAndPassword = True
' checking user fields
With ThisWorkbook.Worksheets(wsName)
If Len(Trim(CStr(.Range("F2").Value))) = 0 Then
MsgBox "Please enter your LAN ID!"
.Range("F2").Activate
GetUsernameAndPassword = False
Exit Function
Else
username = Trim(CStr(.Range("F2").Value))
End If
If Len(Trim(CStr(.Range("F3").Value))) = 0 Then
MsgBox "Please enter your LAN Password!"
.Range("F3").Activate
GetUsernameAndPassword = False
Exit Function
Else
password = Trim(CStr(.Range("F3").Value))
End If
End With
End Function
Function OverrideHandler(ByRef usingSharePoint As Boolean, wsName As String) As Workbook
Dim SharePointFile As String
Dim tempWB As String
Set OverrideHandler = Nothing
' Checking for overrides
With ThisWorkbook.Worksheets(wsName)
' If both overrides are filled
If Len(Trim(CStr(.Range("L4").Value))) > 0 And Len(Trim(CStr(.Range("L5").Value))) > 0 Then
.Range("L4").Activate
.Range("L4").Hyperlinks.Delete
.Range("L4:N4").Borders.LineStyle = xlContinuous
.Range("L4:N4").Borders.Color = RGB(0, 112, 192)
MsgBox "Can't have both override fields populated!"
' If only SP override is filled
ElseIf Len(Trim(CStr(.Range("L4").Value))) > 0 Then
.Range("L4").Hyperlinks.Delete
.Range("L4:N4").Borders.LineStyle = xlContinuous
.Range("L4:N4").Borders.Color = RGB(0, 112, 192)
usingSharePoint = True
SharePointFile = Trim(CStr(.Range("L4").Value))
If Workbooks.CanCheckOut(SharePointFile) = True Then
Workbooks.CheckOut (SharePointFile)
Workbooks.Open (SharePointFile)
Application.Wait (Now + TimeValue("0:00:01"))
tempWB = Replace(returnFileName(SharePointFile, "/"), "%20", " ")
Set OverrideHandler = Workbooks(tempWB)
Else
MsgBox "Master Tracker can't be checked out at this time. Please make sure it is not open on your computer.", vbInformation
Application.StatusBar = ""
End If
' If only file override is filled
ElseIf Len(Trim(CStr(.Range("L5").Value))) > 0 Then
Set OverrideHandler = AttachMasterTracker(wsName, Trim(CStr(.Range("L5").Value)))
' If nothing is filled
Else
usingSharePoint = True
SharePointFile = "..."
If Workbooks.CanCheckOut(SharePointFile) = True Then
Workbooks.CheckOut (SharePointFile)
Workbooks.Open (SharePointFile)
Application.Wait (Now + TimeValue("0:00:01"))
Else
MsgBox "Master Tracker can't be checked out at this time. Please make sure it is not open on your computer.", vbInformation
Application.StatusBar = ""
End If
End If
End With
Exit Function
' Error handler if can't find override file
DocumentHandler:
ThisWorkbook.Activate
MsgBox "Please make sure filename is correct!"
OverrideHandler = False
End Function
Sub MonthAdder(localRow As Integer, MasterTracker As Workbook, redValue As Integer, greenValue As Integer, blueValue As Integer, indicator As String, wsName As String)
Dim monthTab As String: monthTab = ""
Dim monthString As String
Dim monthNum As Integer: monthNum = 0
Dim lastMasterRow As Integer
Dim releaseYear As String: releaseYear = ""
Dim ws As Variant
Dim wsNew As Worksheet
Dim currentMonth As Integer
Dim currentYear As Integer
' finding release date for wr
If indicator = "Tool" Then
With ThisWorkbook.Worksheets(wsName)
If IsDate(.Range("I" & localRow).Value) And Len(Trim(CStr(.Range("I" & localRow).Value))) > 0 Then
monthString = Format(.Range("I" & localRow).Value, "mmm")
releaseYear = year(.Range("I" & localRow).Value)
monthNum = month(.Range("I" & localRow).Value)
Else
monthString = "TBD"
End If
End With
ElseIf indicator = "Blanks" Or indicator = "No's" Then
With MasterTracker.Worksheets("Intake " & indicator)
If IsDate(.Range("D" & localRow).Value) And Len(Trim(CStr(.Range("D" & localRow).Value))) > 0 Then
monthString = Format(.Range("D" & localRow).Value, "mmm")
releaseYear = year(.Range("D" & localRow).Value)
monthNum = month(.Range("D" & localRow).Value)
Else
monthString = "TBD"
End If
End With
End If
' check if month is out-dated
If monthNum <> 0 Then
currentMonth = month(Date)
currentYear = year(Date)
If currentYear > releaseYear Then
currentMonth = currentMonth + 12
ElseIf currentYear < releaseYear Then
currentMonth = currentMonth - 12
End If
If currentMonth > monthNum Then
monthString = "TBD"
releaseYear = ""
If Abs(currentMonth) - Abs(monthNum) = 1 Then
monthString = Format(Date, "mmm")
releaseYear = year(Date)
End If
End If
End If
For Each ws In MasterTracker.Worksheets
If InStr(ws.Name, monthString) > 0 And InStr(ws.Name, releaseYear) Then
monthTab = ws.Name
Exit For
End If
Next
If Len(monthTab) = 0 Then ' took out: And CInt(releaseYear) <= year(Date) + 3
With MasterTracker
Set wsNew = .Sheets.Add(After:= _
.Sheets(.Sheets.Count - 2))
wsNew.Name = monthString & " " & releaseYear
monthTab = wsNew.Name
' headers
With wsNew
.Range("A2").Value = "UAT-COE Lead"
.Range("B2").Value = "Project Name"
.Range("C2").Value = "WR"
.Range("D2").Value = "Release Date"
.Range("E2").Value = "UAT-COE SME for UAT-COE Sign off"
.Range("F2").Value = "Status"
.Range("A1:F1").Merge
.Range("A1").RowHeight = 18
.Range("A1").Font.Size = 14
.Range("A1").Font.Bold = True
.Range("A2").ColumnWidth = 16.56
.Range("B2").ColumnWidth = 53.78
.Range("C2").ColumnWidth = 16.33
.Range("D2").ColumnWidth = 18.56
.Range("E2").ColumnWidth = 29.78
.Range("F2").ColumnWidth = 40.89
.Range("A1").Value = "UAT-COE Deliverables Review and Sign off (Test Plan, Testable Requirements Doc, Test SN/Cases, Test Results)"
.Range("A2:F2").Interior.Color = RGB(230, 184, 183)
.Range("A1:F1").Interior.Color = RGB(0, 176, 240)
.Range("A1").Font.Bold = True
.Range("A1:F1").WrapText = True
.Range("A2:F2").WrapText = True
.Range("A1:F2").Borders.LineStyle = xlContinuous
.Range("A1:F2").HorizontalAlignment = xlCenter
End With
End With
End If
' Finding last used row on master tracker to use as a marker when updating tracker
With MasterTracker.Worksheets(monthTab)
lastMasterRow = .Cells(.Rows.Count, "C").End(xlUp).row + 1
End With
' Updating master tracker programmatically
If indicator = "Tool" Then
With MasterTracker.Worksheets(monthTab)
' Formatting
FormatRow MasterTracker.Worksheets(monthTab), lastMasterRow, redValue, greenValue, blueValue
.Range("A" & lastMasterRow).Value = "TBD"
.Range("B" & lastMasterRow).Value = CStr(ThisWorkbook.Worksheets(wsName).Range("F" & localRow).Value)
.Range("C" & lastMasterRow).Value = CStr(ThisWorkbook.Worksheets(wsName).Range("A" & localRow).Value)
.Range("D" & lastMasterRow).Value = CStr(ThisWorkbook.Worksheets(wsName).Range("I" & localRow).Value)
.Range("F" & lastMasterRow).Value = "Initiation - " & Trim(CStr(ThisWorkbook.Worksheets(wsName).Range("J" & localRow).Value))
End With
ThisWorkbook.Worksheets(wsName).Range("O" & localRow).Value = "Pushed to " & monthTab
ElseIf indicator = "Blanks" Or indicator = "No's" Then
With MasterTracker.Worksheets(monthTab)
' Formatting
FormatRow MasterTracker.Worksheets(monthTab), lastMasterRow, redValue, greenValue, blueValue
.Range("A" & lastMasterRow).Value = "TBD"
.Range("B" & lastMasterRow).Value = CStr(MasterTracker.Worksheets("Intake " & indicator).Range("B" & localRow).Value)
.Range("C" & lastMasterRow).Value = CStr(MasterTracker.Worksheets("Intake " & indicator).Range("C" & localRow).Value)
.Range("D" & lastMasterRow).Value = CStr(MasterTracker.Worksheets("Intake " & indicator).Range("D" & localRow).Value)
.Range("F" & lastMasterRow).Value = "Initiation - " & Trim(CStr(MasterTracker.Worksheets("Intake " & indicator).Range("F" & localRow).Value))
' Delete row
MasterTracker.Worksheets("Intake " & indicator).Rows(localRow).EntireRow.Delete
End With
End If
End Sub
Sub FormatRow(targetWS As Worksheet, row As Integer, redValue As Integer, greenValue As Integer, blueValue As Integer)
With targetWS
.Range("A" & row & ":F" & row).Interior.Color = RGB(redValue, greenValue, blueValue)
.Range("A" & row & ":F" & row).Borders.LineStyle = xlContinuous
.Range("A" & row & ":C" & row).NumberFormat = "@"
.Range("E" & row & ":F" & row).NumberFormat = "@"
.Range("D" & row).NumberFormat = "m/d/yyyy"
.Range("A" & row).HorizontalAlignment = xlCenter
.Range("B" & row).HorizontalAlignment = xlLeft
.Range("C" & row & ":F" & row).HorizontalAlignment = xlCenter
.Range("A" & row & ":F" & row).VerticalAlignment = xlCenter
If redValue = 0 And greenValue = 0 And blueValue = 0 Then
.Range("A" & row & ":F" & row).Interior.ColorIndex = 0
End If
End With
End Sub
Sub IntakeBlankOrNoAdder(localRow As Integer, MasterTracker As Workbook, monthTab As String, indicator As String, wsName As String)
Dim lastMasterRow As Integer
' Finding last used row on master tracker to use as a marker when updating tracker
With MasterTracker.Worksheets(monthTab)
lastMasterRow = .Cells(.Rows.Count, "C").End(xlUp).row + 1
End With
' Updating master tracker programmetically
If indicator = "Tool" Then
With MasterTracker.Worksheets(monthTab)
.Range("B" & lastMasterRow).Value = CStr(ThisWorkbook.Worksheets(wsName).Range("F" & localRow).Value)
.Range("C" & lastMasterRow).Value = CStr(ThisWorkbook.Worksheets(wsName).Range("A" & localRow).Value)
.Range("D" & lastMasterRow).Value = CStr(ThisWorkbook.Worksheets(wsName).Range("I" & localRow).Value)
.Range("F" & lastMasterRow).Value = CStr(ThisWorkbook.Worksheets(wsName).Range("J" & localRow).Value)
.Range("G" & lastMasterRow).Value = CStr(ThisWorkbook.Worksheets(wsName).Range("B" & localRow).Value)
.Range("H" & lastMasterRow).Value = CStr(ThisWorkbook.Worksheets(wsName).Range("D" & localRow).Value)
.Range("D" & lastMasterRow).NumberFormat = "m/d/yyyy"
.Range("H" & lastMasterRow).NumberFormat = "m/d/yyyy"
.Range("A" & lastMasterRow & ":H" & lastMasterRow).Borders.LineStyle = xlContinuous
End With
ThisWorkbook.Worksheets(wsName).Range("O" & localRow).Value = "Pushed to " & monthTab
ElseIf indicator = "Blanks" Then
With MasterTracker.Worksheets(monthTab)
.Range("B" & lastMasterRow).Value = CStr(MasterTracker.Worksheets("Intake Blanks").Range("B" & localRow).Value)
.Range("C" & lastMasterRow).Value = CStr(MasterTracker.Worksheets("Intake Blanks").Range("C" & localRow).Value)
.Range("D" & lastMasterRow).Value = CStr(MasterTracker.Worksheets("Intake Blanks").Range("D" & localRow).Value)
.Range("F" & lastMasterRow).Value = CStr(MasterTracker.Worksheets("Intake Blanks").Range("F" & localRow).Value)
.Range("G" & lastMasterRow).Value = CStr(MasterTracker.Worksheets("Intake Blanks").Range("G" & localRow).Value)
.Range("H" & lastMasterRow).Value = CStr(MasterTracker.Worksheets("Intake Blanks").Range("H" & localRow).Value)
.Range("D" & lastMasterRow).NumberFormat = "m/d/yyyy"
.Range("H" & lastMasterRow).NumberFormat = "m/d/yyyy"
.Range("A" & lastMasterRow & ":H" & lastMasterRow).Borders.LineStyle = xlContinuous
MasterTracker.Worksheets("Intake Blanks").Rows(localRow).EntireRow.Delete
End With
End If
End Sub
Sub IntakeBlanksAndNosChecker(MasterTracker As Workbook, username As String, password As String, redValue As Integer, greenValue As Integer, blueValue As Integer, tabChecking As String, wsName As String, ws2Name As String)
Dim lastMTRow As Integer
Dim row As Integer
Dim conn As Object 'Variable for ADODB.Connection object
Dim rs As Object 'Variable for ADODB.Recordset object
Dim workRequest As String
Dim extra As Integer
Dim localCounter As Integer
Dim secondSheetSpot As Integer
Dim checkRow As String
If tabChecking = "Intake Blanks" Then
checkRow = "3"
Else
checkRow = "5"
End If
' Instantiating connection objects
Set conn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
With MasterTracker.Worksheets(tabChecking)
lastMTRow = .Cells(.Rows.Count, "C").End(xlUp).row
On Error GoTo ConnectionHandler3
conn.ConnectionString = "Provider=IBMDADB2.1;UID=" & username & ";PWD=" & password & ";Data Source=...;ProviderType=OLEDB"
conn.Open
' Iterating through WRs
On Error GoTo 0
For row = 3 To lastMTRow
' update progress bar
CheckProgress lastMTRow, row, checkRow, "start"
workRequest = Trim(CStr(.Range("C" & row).Value))
rs.Open "Select v..." & _
"... from ... as t1 inner join ... as t2 on t1... = t2... where t1.... = '" & workRequest & "' with ur", conn
If Not (rs.BOF Or rs.EOF) Then
.Range("D" & row).Value = rs.Fields(0).Value
.Range("F" & row).Value = rs.Fields(1).Value
.Range("G" & row).Value = rs.Fields(2).Value
.Range("D" & row).NumberFormat = "m/d/yyyy"
End If
rs.Close
Next
' Closing connection
conn.Close
' Checking for moveable WRs
For row = 3 To lastMTRow
' update progress bar
CheckProgress lastMTRow, row, checkRow, "end"
If Trim(CStr(.Range("F" & row).Value)) <> "In_Progress" And Trim(CStr(.Range("F" & row).Value)) <> "System_Route_Work" Then ' Add system_route_work
If Trim(CStr(.Range("F" & row).Value)) <> "Withdrawn" And Trim(CStr(.Range("F" & row).Value)) <> "Closed" Then
If Len(Trim(CStr(.Range("G" & row).Value))) > 0 Then
If Trim(CStr(.Range("G" & row).Value)) = "Yes" Then
' Add to months
If tabChecking = "Intake Blanks" Then
MonthAdder row, MasterTracker, redValue, greenValue, blueValue, "Blanks", wsName
ElseIf tabChecking = "Intake No's" Then
MonthAdder row, MasterTracker, redValue, greenValue, blueValue, "No's", wsName
End If
row = row - 1
Else ' UAT = No
' Add to Intake No's
If tabChecking = "Intake Blanks" Then
IntakeBlankOrNoAdder row, MasterTracker, "Intake No's", "Blanks", wsName
row = row - 1
End If
End If ' End of UAT yes/no
End If ' End of UAT blank
Else ' Is Withdrawn or Closed
' Add to Intake No's
If tabChecking = "Intake Blanks" Then
IntakeBlankOrNoAdder row, MasterTracker, "Intake No's", "Blanks", wsName
row = row - 1
End If
End If ' End of Withdrawn check
End If ' End of In Progress check
Next
End With
Exit Sub
ConnectionHandler3:
ThisWorkbook.Activate
MsgBox "Unable to connect to database. Was checking Master Tracker."
End Sub
Sub NotTestingChecker(MasterTracker As Workbook, username As String, password As String, wsName As String, ws2Name As String)
Dim conn As Object 'Variable for ADODB.Connection object
Dim rs As Object 'Variable for ADODB.Recordset object
Dim yesWorkRequests As Collection: Set yesWorkRequests = New Collection
Dim lastMTRow As Integer
Dim workRequest As String
Dim tempState As String
Dim row As Integer
' Instantiating connection objects
Set conn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
On Error GoTo ConnectionHandler5
conn.ConnectionString = "Provider=IBMDADB2.1;UID=" & username & ";PWD=" & password & ";Data Source=...;ProviderType=OLEDB"
conn.Open
On Error GoTo 0
With MasterTracker.Worksheets("Not Testing")
lastMTRow = .Cells(.Rows.Count, "C").End(xlUp).row
For row = 2 To lastMTRow
' update progress bar
CheckProgress lastMTRow, row, "7", "none"
workRequest = Trim(CStr(.Range("C" & row).Value))
rs.Open "Select ... " & _
"from ... as t1 inner join ... as t2 on t1.... = t2.... where t1.... = '" & workRequest & "' with ur", conn
If Not (rs.BOF Or rs.EOF) Then
tempState = rs.Fields(1).Value
If tempState <> "Withdrawn" And tempState <> "Closed" Then
If rs.Fields(0).Value = "Yes" Then
If Len(CStr(rs.Fields(2).Value)) > 0 Then
If CDate(rs.Fields(2).Value) >= Date Then
yesWorkRequests.Add workRequest
End If
End If
End If
End If
End If
rs.Close
Next
End With
If yesWorkRequests.Count > 0 Then
EmailGenerator yesWorkRequests, "notTesting", username, password, wsName
End If
Exit Sub
ConnectionHandler5:
ThisWorkbook.Activate
MsgBox "Unable to connect to database. Was checking Master Tracker."
End Sub
Sub TBDChecker(MasterTracker As Workbook, username As String, password As String, wsName As String, ws2Name As String)
Dim conn As Object 'Variable for ADODB.Connection object
Dim rs As Object 'Variable for ADODB.Recordset object
Dim flaggedTBDs As Collection: Set flaggedTBDs = New Collection
Dim lastMTRow As Integer
Dim workRequest As String
Dim tempState As String
Dim row As Integer
' Instantiating connection objects
Set conn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
On Error GoTo ConnectionHandler6
conn.ConnectionString = "Provider=IBMDADB2.1;UID=" & username & ";PWD=" & password & ";Data Source=...;ProviderType=OLEDB"
conn.Open
On Error GoTo 0
With MasterTracker.Worksheets("TBD")
lastMTRow = .Cells(.Rows.Count, "C").End(xlUp).row
For row = 3 To lastMTRow
' update progress bar
CheckProgress lastMTRow, row, "9", "none"
workRequest = Trim(CStr(.Range("C" & row).Value))
rs.Open "Select ..." & _
"from ... as t1 inner join ... as t2 on t1.... = t2.... where t1.... = '" & workRequest & "' with ur", conn
If Not (rs.BOF Or rs.EOF) Then
tempState = rs.Fields(1).Value
If tempState = "Withdrawn" Or tempState = "Closed" Or tempState = "Released" Then
' move to withdrawn tab & delete
AddTBDtoWithdrawnTab row, workRequest, rs.Fields(0).Value, rs.Fields(1).Value, rs.Fields(2).Value, MasterTracker
.Rows(row).EntireRow.Delete
row = row - 1
ElseIf tempState <> "Rejected" And tempState <> "In_Progress" And tempState <> "System_Route_Work" And tempState <> "Replan" And tempState <> "Pending_CCB_Review" Then
If IsNull(rs.Fields(2).Value) = False Then
If CDate(rs.Fields(2).Value) > Date Then
If rs.Fields(0).Value = "Yes" Then
flaggedTBDs.Add workRequest
End If
End If
End If
End If
End If
rs.Close
Next
End With
If flaggedTBDs.Count > 0 Then
EmailGenerator flaggedTBDs, "tbdTab", username, password, wsName
End If
Exit Sub
ConnectionHandler6:
ThisWorkbook.Activate
MsgBox "Unable to connect to database. Was checking Master Tracker."
End Sub
Sub AddTBDtoWithdrawnTab(row As Integer, workRequest As String, involvement As String, state As String, releaseDate As String, MasterTracker As Workbook)
Dim withdrawnTab As Worksheet
Dim lastWithdrawnRow As Integer
Dim ws As Variant
' finding withdrawn tab
For Each ws In MasterTracker.Worksheets
If InStr(LCase(ws.Name), "withdrawn") Then
Set withdrawnTab = ws
Exit For
End If
Next
With withdrawnTab
lastWithdrawnRow = .Cells(.Rows.Count, "C").End(xlUp).row + 1
.Range("A" & lastWithdrawnRow).Value = MasterTracker.Worksheets("TBD").Range("A" & row).Value
.Range("B" & lastWithdrawnRow).Value = MasterTracker.Worksheets("TBD").Range("B" & row).Value
.Range("C" & lastWithdrawnRow).Value = workRequest
.Range("D" & lastWithdrawnRow).Value = releaseDate
.Range("E" & lastWithdrawnRow).Value = MasterTracker.Worksheets("TBD").Range("E" & row).Value
.Range("F" & lastWithdrawnRow).Value = state
.Range("G" & lastWithdrawnRow).Value = involvement
FormatRow withdrawnTab, lastWithdrawnRow, 0, 0, 0
End With
End Sub
Public Function BookOpen(strBookName As String) As Boolean
Dim oBk As Workbook
On Error Resume Next
Set oBk = Workbooks(strBookName)
On Error GoTo 0
If oBk Is Nothing Then
BookOpen = False
Else
BookOpen = True
End If
End Function
Sub FinalEmailGenerator(colorValue As String)
Dim olApp As Outlook.Application
Dim newMail As Outlook.MailItem
Dim emailBody As String
Dim emailSig As String
Dim fontColor As String
Set olApp = CreateObject("Outlook.Application") 'Another option: Set olApp = New Outlook.Application
Set newMail = olApp.CreateItem(olMailItem)