Private Sub UserForm_Activate()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.EnableEvents = False
UnprotectAllWorksheets
Dim myRGB_Red As Long: myRGB_Red = RGB(255, 0, 0)
Dim myRGB_Blue As Long: myRGB_Blue = RGB(0, 112, 192)
Dim myRGB_Green As Long: myRGB_Green = RGB(0, 176, 80)
Dim myRGB_Yellow As Long: myRGB_Yellow = RGB(255, 255, 0)
ThisWorkbook.Worksheets("WEEKLY").Select
Dim lrSCA, lrSCB, lrTBA, lrWA, lrWB, lrEPT, lrFPT, lrMPA1, lrMPA2, lrMPB1, lrMPB2 As Long
Dim vCol
'-----------------------------------------------------------------------------------------
'SHUTTLE CAR A
'-----------------------------------------------------------------------------------------
Dim xRowSCA As Long
'lrSCA = Sheets("WEEKLY").Range("P6").SpecialCells(xlCellTypeLastCell).Row
lrSCA = Sheets("WEEKLY").Range("P" & Rows.Count).End(xlUp).Row
For xRowSCA = lrSCA To 6 Step -1 '6 is the first row with data
If cells(xRowSCA, "P") <> "" And cells(xRowSCA, "P") <> "N/A" And cells(xRowSCA, "C") = "A" Then
cells(xRowSCA, "P").Select
Select Case ActiveCell
Case Is = "DB1", "AL1", "PD1", "MG1", "RT1", "DS1": vCol = myRGB_Red
Case Is = "AS1", "MT1", "AM3", "KA1", "BL1", "LP1", "JS1", "SS1", "AW1": vCol = myRGB_Yellow
Case Is = "RH1", "MC1", "MN1", "PP2", "MK1", "RL1", "JP1", "ML1", "JB1", "RW1": vCol = myRGB_Green
Case Is = "GC1", "PP1", "DP1", "AP1", "HO1", "SM1": vCol = myRGB_Blue
End Select
With ActiveCell
LabelInitialsSCA.Caption = .Value
LabelInitialsSCA.BackColor = vCol
End With
STATSFORM.LabelDateSCA.Caption = ActiveCell.Offset(0, 1).Text
STATSFORM.LabelTimeSCA.Caption = ActiveCell.Offset(0, 2).Text
Exit For
End If
Next xRowSCA
'--------------------------------------------------------------------------
'SHUTTLE CAR B
'--------------------------------------------------------------------------
Dim xRowSCB As Long
'lrSCB = Sheets("WEEKLY").Range("P6").SpecialCells(xlCellTypeLastCell).Row
lrSCB = Sheets("WEEKLY").Range("P6" & Rows.Count).End(xlUp).Row
For xRowSCB = lrSCB To 6 Step -1 '6 is the first row with data
If cells(xRowSCB, "P") <> "" And cells(xRowSCB, "P") <> "N/A" And cells(xRowSCB, "C") = "B" Then
cells(xRowSCB, "P").Select
Select Case ActiveCell
Case Is = "DB1", "AL1", "PD1", "MG1", "RT1", "DS1": vCol = myRGB_Red
Case Is = "AS1", "MT1", "AM3", "KA1", "BL1", "LP1", "JS1", "SS1", "AW1": vCol = myRGB_Yellow
Case Is = "RH1", "MC1", "MN1", "PP2", "MK1", "RL1", "JP1", "ML1", "JB1", "RW1": vCol = myRGB_Green
Case Is = "GC1", "PP1", "DP1", "AP1", "HO1", "SM1": vCol = myRGB_Blue
End Select
With ActiveCell
LabelInitialsSCB.Caption = .Value
LabelInitialsSCB.BackColor = vCol
End With
STATSFORM.LabelDateSCB.Caption = ActiveCell.Offset(0, 1).Text
STATSFORM.LabelTimeSCB.Caption = ActiveCell.Offset(0, 2).Text
Exit For
End If
Next xRowSCB
'-----------------------------------------------------------------------------------
'WRAPPER A
'-----------------------------------------------------------------------------------
Dim xRowWA As Long
'lrWA = Sheets("WEEKLY").Range("BE6").SpecialCells(xlCellTypeLastCell).Row
lrWA = Sheets("WEEKLY").Range("BE6" & Rows.Count).End(xlUp).Row
For xRowWA = lrWA To 6 Step -1 '6 is the first row with data
If cells(xRowWA, "BE") <> "" And cells(xRowWA, "BE") <> "N/A" And cells(xRowWA, "AJ") = "A" Then
cells(xRowWA, "BE").Select
Select Case ActiveCell
Case Is = "DB1", "AL1", "PD1", "MG1", "RT1", "DS1": vCol = myRGB_Red
Case Is = "AS1", "MT1", "AM3", "KA1", "BL1", "LP1", "JS1", "SS1", "AW1": vCol = myRGB_Yellow
Case Is = "RH1", "MC1", "MN1", "PP2", "MK1", "RL1", "JP1", "ML1", "JB1", "RW1": vCol = myRGB_Green
Case Is = "GC1", "PP1", "DP1", "AP1", "HO1", "SM1": vCol = myRGB_Blue
End Select
With ActiveCell
LabelInitialsWA.Caption = .Value
LabelInitialsWA.BackColor = vCol
End With
STATSFORM.LabelDateWA.Caption = ActiveCell.Offset(0, 1).Text
STATSFORM.LabelTimeWA.Caption = ActiveCell.Offset(0, 2).Text
Exit For
End If
Next xRowWA
'--------------------------------------------------------------------------
'WRAPPER B
'--------------------------------------------------------------------------
Dim xRowWB As Long
'lrWB = Sheets("WEEKLY").Range("BE6").SpecialCells(xlCellTypeLastCell).Row
lrWB = Sheets("WEEKLY").Range("BE6" & Rows.Count).End(xlUp).Row
For xRowWB = lrWB To 6 Step -1 '6 is the first row with data
If cells(xRowWB, "BE") <> "" And cells(xRowWB, "BE") <> "N/A" And cells(xRowWB, "AJ") = "B" Then
cells(xRowWB, "BE").Select
Select Case ActiveCell
Case Is = "DB1", "AL1", "PD1", "MG1", "RT1", "DS1": vCol = myRGB_Red
Case Is = "AS1", "MT1", "AM3", "KA1", "BL1", "LP1", "JS1", "SS1", "AW1": vCol = myRGB_Yellow
Case Is = "RH1", "MC1", "MN1", "PP2", "MK1", "RL1", "JP1", "ML1", "JB1", "RW1": vCol = myRGB_Green
Case Is = "GC1", "PP1", "DP1", "AP1", "HO1", "SM1": vCol = myRGB_Blue
End Select
With ActiveCell
LabelInitialsWB.Caption = .Value
LabelInitialsWB.BackColor = vCol
End With
STATSFORM.LabelDateWB.Caption = ActiveCell.Offset(0, 1).Text
STATSFORM.LabelTimeWB.Caption = ActiveCell.Offset(0, 2).Text
Exit For
End If
Next xRowWB
'---------------------------------------------------------------------------------------
'FPT
'---------------------------------------------------------------------------------------
Dim xRowFPT As Long
'lrFPT = Sheets("WEEKLY").Range("CN6").SpecialCells(xlCellTypeLastCell).Row
lrFPT = Sheets("WEEKLY").Range("CN6" & Rows.Count).End(xlUp).Row
For xRowFPT = lrFPT To 6 Step -1 '6 is the first row with data
If cells(xRowFPT, "CN") <> "" And cells(xRowFPT, "CN") <> "N/A" Then
cells(xRowFPT, "CN").Select
Select Case ActiveCell
Case Is = "DB1", "AL1", "PD1", "MG1", "RT1", "DS1": vCol = myRGB_Red
Case Is = "AS1", "MT1", "AM3", "KA1", "BL1", "LP1", "JS1", "SS1", "AW1": vCol = myRGB_Yellow
Case Is = "RH1", "MC1", "MN1", "PP2", "MK1", "RL1", "JP1", "ML1", "JB1", "RW1": vCol = myRGB_Green
Case Is = "GC1", "PP1", "DP1", "AP1", "HO1", "SM1": vCol = myRGB_Blue
End Select
With ActiveCell
LabelInitialsFPT.Caption = .Value
LabelInitialsFPT.BackColor = vCol
End With
STATSFORM.LabelDateFPT.Caption = ActiveCell.Offset(0, 1).Text
STATSFORM.LabelTimeFPT.Caption = ActiveCell.Offset(0, 2).Text
Exit For
End If
Next xRowFPT
'------------------------------------------------------------------------------------
'EPT
'------------------------------------------------------------------------------------
Dim xRowEPT As Long
'lrEPT = Sheets("WEEKLY").Range("BW6").SpecialCells(xlCellTypeLastCell).Row
lrEPT = Sheets("WEEKLY").Range("BW6" & Rows.Count).End(xlUp).Row
For xRowEPT = lrEPT To 6 Step -1 '6 is the first row with data
If cells(xRowEPT, "BW") <> "" And cells(xRowEPT, "BW") <> "N/A" Then
cells(xRowEPT, "BW").Select
Select Case ActiveCell
Case Is = "DB1", "AL1", "PD1", "MG1", "RT1", "DS1": vCol = myRGB_Red
Case Is = "AS1", "MT1", "AM3", "KA1", "BL1", "LP1", "JS1", "SS1", "AW1": vCol = myRGB_Yellow
Case Is = "RH1", "MC1", "MN1", "PP2", "MK1", "RL1", "JP1", "ML1", "JB1", "RW1": vCol = myRGB_Green
Case Is = "GC1", "PP1", "DP1", "AP1", "HO1", "SM1": vCol = myRGB_Blue
End Select
With ActiveCell
LabelInitialsEPT.Caption = .Value
LabelInitialsEPT.BackColor = vCol
End With
STATSFORM.LabelDateEPT.Caption = ActiveCell.Offset(0, 1).Text
STATSFORM.LabelTimeEPT.Caption = ActiveCell.Offset(0, 2).Text
Exit For
End If
Next xRowEPT
'------------------------------------------------------------------------------------
'TBA
'------------------------------------------------------------------------------------
Dim xRowTBA As Long
'lrTBA = Sheets("WEEKLY").Range("AG6").SpecialCells(xlCellTypeLastCell).Row
lrTBA = Sheets("WEEKLY").Range("AG6" & Rows.Count).End(xlUp).Row
For xRowTBA = lrTBA To 6 Step -1 '6 is the first row with data
If cells(xRowTBA, "AG") <> "" And cells(xRowTBA, "AG") <> "N/A" Then
cells(xRowTBA, "AG").Select
Select Case ActiveCell
Case Is = "DB1", "AL1", "PD1", "MG1", "RT1", "DS1": vCol = myRGB_Red
Case Is = "AS1", "MT1", "AM3", "KA1", "BL1", "LP1", "JS1", "SS1", "AW1": vCol = myRGB_Yellow
Case Is = "RH1", "MC1", "MN1", "PP2", "MK1", "RL1", "JP1", "ML1", "JB1", "RW1": vCol = myRGB_Green
Case Is = "GC1", "PP1", "DP1", "AP1", "HO1", "SM1": vCol = myRGB_Blue
End Select
With ActiveCell
LabelInitialsTBA.Caption = .Value
LabelInitialsTBA.BackColor = vCol
End With
STATSFORM.LabelDateTBA.Caption = ActiveCell.Offset(0, 1).Text
STATSFORM.LabelTimeTBA.Caption = ActiveCell.Offset(0, 2).Text
Exit For
End If
Next xRowTBA
'------------------------------------------------------------------------------------
'MARKEM PRINTERS
'------------------------------------------------------------------------------------
Dim xRowMPA1 As Long
'lrMPA1 = Sheets("WEEKLY").Range("DC6").SpecialCells(xlCellTypeLastCell).Row
lrMPA1 = Sheets("WEEKLY").Range("DC6" & Rows.Count).End(xlUp).Row
For xRowMPA1 = lrMPA1 To 6 Step -1 '6 is the first row with data
If cells(xRowMPA1, "DC") <> "" And cells(xRowMPA1, "DC") <> "N/A" Then
cells(xRowMPA1, "DC").Select
Select Case ActiveCell
Case Is = "DB1", "AL1", "PD1", "MG1", "RT1", "DS1": vCol = myRGB_Red
Case Is = "AS1", "MT1", "AM3", "KA1", "BL1", "LP1", "JS1", "SS1", "AW1": vCol = myRGB_Yellow
Case Is = "RH1", "MC1", "MN1", "PP2", "MK1", "RL1", "JP1", "ML1", "JB1", "RW1": vCol = myRGB_Green
Case Is = "GC1", "PP1", "DP1", "AP1", "HO1", "SM1": vCol = myRGB_Blue
End Select
With ActiveCell
LabelInitialsMPA1.Caption = .Value
LabelInitialsMPA1.BackColor = vCol
End With
STATSFORM.LabelDateMPA1.Caption = ActiveCell.Offset(0, 1).Text
STATSFORM.LabelTimeMPA1.Caption = ActiveCell.Offset(0, 2).Text
Exit For
End If
Next xRowMPA1
'------------------------------------------------------------------------------------
Dim xRowMPA2 As Long
'lrMPA2 = Sheets("WEEKLY").Range("DR6").SpecialCells(xlCellTypeLastCell).Row
lrMPA2 = Sheets("WEEKLY").Range("DR6" & Rows.Count).End(xlUp).Row
For xRowMPA2 = lrMPA2 To 6 Step -1 '6 is the first row with data
If cells(xRowMPA2, "DR") <> "" And cells(xRowMPA2, "DR") <> "N/A" Then
cells(xRowMPA2, "DR").Select
Select Case ActiveCell
Case Is = "DB1", "AL1", "PD1", "MG1", "RT1", "DS1": vCol = myRGB_Red
Case Is = "AS1", "MT1", "AM3", "KA1", "BL1", "LP1", "JS1", "SS1", "AW1": vCol = myRGB_Yellow
Case Is = "RH1", "MC1", "MN1", "PP2", "MK1", "RL1", "JP1", "ML1", "JB1", "RW1": vCol = myRGB_Green
Case Is = "GC1", "PP1", "DP1", "AP1", "HO1", "SM1": vCol = myRGB_Blue
End Select
With ActiveCell
LabelInitialsMPA2.Caption = .Value
LabelInitialsMPA2.BackColor = vCol
End With
STATSFORM.LabelDateMPA2.Caption = ActiveCell.Offset(0, 1).Text
STATSFORM.LabelTimeMPA2.Caption = ActiveCell.Offset(0, 2).Text
Exit For
End If
Next xRowMPA2
'------------------------------------------------------------------------------------
Dim xRowMPB1 As Long
'lrMPB1 = Sheets("WEEKLY").Range("EG6").SpecialCells(xlCellTypeLastCell).Row
lrMPB1 = Sheets("WEEKLY").Range("EG6" & Rows.Count).End(xlUp).Row
For xRowMPB1 = lrMPB1 To 6 Step -1 '6 is the first row with data
If cells(xRowMPB1, "EG") <> "" And cells(xRowMPB1, "EG") <> "N/A" Then
cells(xRowMPB1, "EG").Select
Select Case ActiveCell
Case Is = "DB1", "AL1", "PD1", "MG1", "RT1", "DS1": vCol = myRGB_Red
Case Is = "AS1", "MT1", "AM3", "KA1", "BL1", "LP1", "JS1", "SS1", "AW1": vCol = myRGB_Yellow
Case Is = "RH1", "MC1", "MN1", "PP2", "MK1", "RL1", "JP1", "ML1", "JB1", "RW1": vCol = myRGB_Green
Case Is = "GC1", "PP1", "DP1", "AP1", "HO1", "SM1": vCol = myRGB_Blue
End Select
With ActiveCell
LabelInitialsMPB1.Caption = .Value
LabelInitialsMPB1.BackColor = vCol
End With
STATSFORM.LabelDateMPB1.Caption = ActiveCell.Offset(0, 1).Text
STATSFORM.LabelTimeMPB1.Caption = ActiveCell.Offset(0, 2).Text
Exit For
End If
Next xRowMPB1
'------------------------------------------------------------------------------------
Dim xRowMPB2 As Long
'lrMPB2 = Sheets("WEEKLY").Range("EV6").SpecialCells(xlCellTypeLastCell).Row
lrMPB2 = Sheets("WEEKLY").Range("EV6" & Rows.Count).End(xlUp).Row
For xRowMPB2 = lrMPB2 To 6 Step -1 '6 is the first row with data
If cells(xRowMPB2, "EV") <> "" And cells(xRowMPB2, "EV") <> "N/A" Then
cells(xRowMPB2, "EV").Select
Select Case ActiveCell
Case Is = "DB1", "AL1", "PD1", "MG1", "RT1", "DS1": vCol = myRGB_Red
Case Is = "AS1", "MT1", "AM3", "KA1", "BL1", "LP1", "JS1", "SS1", "AW1": vCol = myRGB_Yellow
Case Is = "RH1", "MC1", "MN1", "PP2", "MK1", "RL1", "JP1", "ML1", "JB1", "RW1": vCol = myRGB_Green
Case Is = "GC1", "PP1", "DP1", "AP1", "HO1", "SM1": vCol = myRGB_Blue
End Select
With ActiveCell
LabelInitialsMPB2.Caption = .Value
LabelInitialsMPB2.BackColor = vCol
End With
STATSFORM.LabelDateMPB2.Caption = ActiveCell.Offset(0, 1).Text
STATSFORM.LabelTimeMPB2.Caption = ActiveCell.Offset(0, 2).Text
Exit For
End If
Next xRowMPB2
ProtectAllWorksheets
Application.ScreenUpdating = True
Application.DisplayAlerts = True
aaaaaLockandProtect
End Sub