'Populate BU6A Tab
For lngCol = 2 To 20
If (Cells(2, lngCol) = "Projection") Then
Range(Columns(lngCol), Columns(lngCol + 4)).Select
Selection.Insert Shift:=xlToRight
Cells(2, lngCol).Value = "Days Over 30"
Cells(2, lngCol + 1).Value = "NCR Number"
Cells(2, lngCol + 2).Value = "Disposition"
Cells(2, lngCol + 3).Value = ">30 with NCR"
Cells(2, lngCol + 4).Value = ">30 with Disposition"
Range(Cells(2, lngCol), Cells(2, lngCol)).ColumnWidth = 6.71
Range(Cells(2, lngCol + 1), Cells(1, lngCol + 4)).ColumnWidth = 13.86
Range(Cells(2, lngCol), Cells(2, lngCol + 4)).Select
Selection.WrapText = True
Range(Columns(1), Columns(lngCol + 4)).HorizontalAlignment = xlCenter
Range(Cells(3, lngCol), Cells(3, lngCol)).Formula = "=IF(D3>30,D3-30,"""")"
Range(Cells(3, lngCol + 1), Cells(3, lngCol + 1)).Formula = "=IF(OR(VLOOKUP(C3,$AF$3:$AJ$" & Cells(Rows.Count, lngCol + 18).End(xlUp).Row & ",3,0)=0,ISERROR(VLOOKUP(C3,$AF$3:$AJ$" & Cells(Rows.Count, lngCol + 18).End(xlUp).Row & ",3,0))),"""",VLOOKUP(C3,$AF$3:$AJ$" & Cells(Rows.Count, lngCol + 18).End(xlUp).Row & ",3,0))"
Range(Cells(3, lngCol + 2), Cells(3, lngCol + 2)).Formula = "=IF(OR(VLOOKUP(C3,$AF$3:$AJ$" & Cells(Rows.Count, lngCol + 18).End(xlUp).Row & ",5,0)=0,ISERROR(VLOOKUP(C3,$AF$3:$AJ$" & Cells(Rows.Count, lngCol + 18).End(xlUp).Row & ",5,0))),"""",VLOOKUP(C3,$AF$3:$AJ$" & Cells(Rows.Count, lngCol + 18).End(xlUp).Row & ",5,0))"
Range(Cells(3, lngCol), Cells(3, lngCol + 2)).Copy
Range(Cells(4, lngCol), Cells(Cells(Rows.Count, 1).End(xlUp).Row - 2, lngCol + 2)).PasteSpecial Paste:=xlPasteFormulas
Range(Cells(3, lngCol), Cells(Cells(Rows.Count, 1).End(xlUp).Row - 2, lngCol + 2)).Copy
Range(Cells(3, lngCol), Cells(Cells(Rows.Count, 1).End(xlUp).Row - 2, lngCol + 2)).PasteSpecial Paste:=xlPasteValues
Exit For
End If
Next lngCol
For lngRow = 3 To Cells(Rows.Count, 1).End(xlUp).Row - 1
If (Cells(lngRow, lngCol) = "") Then
Cells(lngRow, lngCol).ClearContents
ElseIf (Cells(lngRow, lngCol) <= 0) Then
Cells(lngRow, lngCol).ClearContents
End If
Next lngRow
For lngRow = 3 To Cells(Rows.Count, 1).End(xlUp).Row - 1
If IsError(Cells(lngRow, lngCol + 1)) Then
Cells(lngRow, lngCol + 1).ClearContents
ElseIf Cells(lngRow, lngCol + 1) = "" Then
Cells(lngRow, lngCol + 1).ClearContents
End If
Next lngRow
For lngRow = 3 To Cells(Rows.Count, 1).End(xlUp).Row - 1
If IsError(Cells(lngRow, lngCol + 2)) Then
Cells(lngRow, lngCol + 2).ClearContents
ElseIf Cells(lngRow, lngCol + 2) = "" Then
Cells(lngRow, lngCol + 2).ClearContents
End If
Next lngRow
For lngCol = 2 To 20
If (Cells(2, lngCol) = "Days Over 30") Then
Range(Cells(3, lngCol + 3), Cells(3, lngCol + 3)).Formula = "=IF(AND(" & ActiveSheet.Cells(3, lngCol).Address & ">0," & ActiveSheet.Cells(3, lngCol + 1).Address & "<>""""),""X"","""")"
Cells(3, lngCol + 3).Formula = Application.ConvertFormula(Cells(3, lngCol + 3).Formula, xlA1, xlA1, xlRelative)
Range(Cells(3, lngCol + 4), Cells(3, lngCol + 4)).Formula = "=IF(AND(" & ActiveSheet.Cells(3, lngCol).Address & ">0," & ActiveSheet.Cells(3, lngCol + 2).Address & "<>""""),""X"","""")"
Cells(3, lngCol + 4).Formula = Application.ConvertFormula(Cells(3, lngCol + 4).Formula, xlA1, xlA1, xlRelative)
Range(Cells(3, lngCol + 3), Cells(3, lngCol + 4)).Copy
Range(Cells(4, lngCol + 3), Cells(Cells(Rows.Count, 1).End(xlUp).Row - 2, lngCol + 4)).PasteSpecial Paste:=xlPasteFormulas
Range(Cells(3, lngCol + 3), Cells(Cells(Rows.Count, 1).End(xlUp).Row - 2, lngCol + 4)).Copy
Range(Cells(3, lngCol + 3), Cells(Cells(Rows.Count, 1).End(xlUp).Row - 2, lngCol + 4)).PasteSpecial Paste:=xlPasteValues
Exit For
End If
Next lngCol
For lngRow = 3 To Cells(Rows.Count, 1).End(xlUp).Row - 1
If IsError(Cells(lngRow, lngCol + 3)) Then
Cells(lngRow, lngCol + 3).ClearContents
ElseIf Cells(lngRow, lngCol + 3) = "" Then
Cells(lngRow, lngCol + 3).ClearContents
End If
Next lngRow
For lngRow = 3 To Cells(Rows.Count, 1).End(xlUp).Row - 1
If IsError(Cells(lngRow, lngCol + 4)) Then
Cells(lngRow, lngCol + 4).ClearContents
ElseIf Cells(lngRow, lngCol + 4) = "" Then
Cells(lngRow, lngCol + 4).ClearContents
End If
Next lngRow
For lngCol = 1 To 22
If (Cells(2, lngCol) = "Planner") Then
Plan_Col = lngCol
Exit For
End If
Next lngCol
For lngCol = 1 To 22
If (Cells(2, lngCol) = "Days Over 30") Then
Over_30_Col = lngCol
Exit For
End If
Next lngCol
For lngRow = 2 To Cells(Rows.Count, 1).End(xlUp).Row - 1
If (Cells(lngRow, Plan_Col) = "53 Total") Then
Cells(lngRow, Over_30_Col).Formula = "=COUNTA(" & Range(Cells(3, Over_30_Col), Cells(lngRow - 1, Over_30_Col)).Address & ")"
Cells(lngRow, Over_30_Col).Formula = Application.ConvertFormula(Cells(lngRow, Over_30_Col).Formula, xlA1, xlA1, xlRelative)
Cells(lngRow, Over_30_Col).Copy Range(Cells(lngRow, Over_30_Col + 1), Cells(lngRow, Over_30_Col + 4))
Cells(lngRow, Over_30_Col + 3).Copy
Sheets("STATS").Range("G43").PasteSpecial Paste:=xlPasteValues
Cells(lngRow, Over_30_Col + 4).Copy
Sheets("STATS").Range("H43").PasteSpecial Paste:=xlPasteValues
Exit For
End If
Next lngRow
For lngRow = 2 To Cells(Rows.Count, 1).End(xlUp).Row - 1
If (Cells(lngRow, Plan_Col) = "53 Total") Then
row_53 = Cells(lngRow, Plan_Col).Row
Exit For
End If
Next lngRow
For lngRow = 2 To Cells(Rows.Count, 1).End(xlUp).Row - 1
If (Cells(lngRow, Plan_Col) = "60 Total") Then
Cells(lngRow, Over_30_Col).Formula = "=COUNTA(" & Range(Cells(row_53 + 1, Over_30_Col), Cells(lngRow - 1, Over_30_Col)).Address & ")"
Cells(lngRow, Over_30_Col).Formula = Application.ConvertFormula(Cells(lngRow, Over_30_Col).Formula, xlA1, xlA1, xlRelative)
Cells(lngRow, Over_30_Col).Copy Range(Cells(lngRow, Over_30_Col + 1), Cells(lngRow, Over_30_Col + 4))
Cells(lngRow, Over_30_Col + 3).Copy
Sheets("STATS").Range("G44").PasteSpecial Paste:=xlPasteValues
Cells(lngRow, Over_30_Col + 4).Copy
Sheets("STATS").Range("H44").PasteSpecial Paste:=xlPasteValues
Exit For
End If
Next lngRow
For lngRow = 2 To Cells(Rows.Count, 1).End(xlUp).Row - 1
If (Cells(lngRow, Plan_Col) = "60 Total") Then
row_60 = Cells(lngRow, Plan_Col).Row
Exit For
End If
Next lngRow
For lngRow = 2 To Cells(Rows.Count, 1).End(xlUp).Row - 1
If (Cells(lngRow, Plan_Col) = "69 Total") Then
Cells(lngRow, Over_30_Col).Formula = "=COUNTA(" & Range(Cells(row_60 + 1, Over_30_Col), Cells(lngRow - 1, Over_30_Col)).Address & ")"
Cells(lngRow, Over_30_Col).Formula = Application.ConvertFormula(Cells(lngRow, Over_30_Col).Formula, xlA1, xlA1, xlRelative)
Cells(lngRow, Over_30_Col).Copy Range(Cells(lngRow, Over_30_Col + 1), Cells(lngRow, Over_30_Col + 4))
Cells(lngRow, Over_30_Col + 3).Copy
Sheets("STATS").Range("G45").PasteSpecial Paste:=xlPasteValues
Cells(lngRow, Over_30_Col + 4).Copy
Sheets("STATS").Range("H45").PasteSpecial Paste:=xlPasteValues
Exit For
End If
Next lngRow
For lngRow = 2 To Cells(Rows.Count, 1).End(xlUp).Row - 1
If (Cells(lngRow, Plan_Col) = "69 Total") Then
row_69 = Cells(lngRow, Plan_Col).Row
Exit For
End If
Next lngRow
For lngRow = 2 To Cells(Rows.Count, 1).End(xlUp).Row - 1
If (Cells(lngRow, Plan_Col) = "72 Total") Then
Cells(lngRow, Over_30_Col).Formula = "=COUNTA(" & Range(Cells(row_69 + 1, Over_30_Col), Cells(lngRow - 1, Over_30_Col)).Address & ")"
Cells(lngRow, Over_30_Col).Formula = Application.ConvertFormula(Cells(lngRow, Over_30_Col).Formula, xlA1, xlA1, xlRelative)
Cells(lngRow, Over_30_Col).Copy Range(Cells(lngRow, Over_30_Col + 1), Cells(lngRow, Over_30_Col + 4))
Cells(lngRow, Over_30_Col + 3).Copy
Sheets("STATS").Range("G46").PasteSpecial Paste:=xlPasteValues
Cells(lngRow, Over_30_Col + 4).Copy
Sheets("STATS").Range("H46").PasteSpecial Paste:=xlPasteValues
Exit For
End If
Next lngRow
For lngRow = 2 To Cells(Rows.Count, 1).End(xlUp).Row - 1
If (Cells(lngRow, Plan_Col) = "72 Total") Then
row_72 = Cells(lngRow, Plan_Col).Row
Exit For
End If
Next lngRow
For lngRow = 2 To Cells(Rows.Count, 1).End(xlUp).Row - 1
If (Cells(lngRow, Plan_Col) = "73 Total") Then
Cells(lngRow, Over_30_Col).Formula = "=COUNTA(" & Range(Cells(row_72 + 1, Over_30_Col), Cells(lngRow - 1, Over_30_Col)).Address & ")"
Cells(lngRow, Over_30_Col).Formula = Application.ConvertFormula(Cells(lngRow, Over_30_Col).Formula, xlA1, xlA1, xlRelative)
Cells(lngRow, Over_30_Col).Copy Range(Cells(lngRow, Over_30_Col + 1), Cells(lngRow, Over_30_Col + 4))
Cells(lngRow, Over_30_Col + 3).Copy
Sheets("STATS").Range("G47").PasteSpecial Paste:=xlPasteValues
Cells(lngRow, Over_30_Col + 4).Copy
Sheets("STATS").Range("H47").PasteSpecial Paste:=xlPasteValues
Exit For
End If
Next lngRow
For lngRow = 2 To Cells(Rows.Count, 1).End(xlUp).Row - 1
If (Cells(lngRow, Plan_Col) = "73 Total") Then
row_73 = Cells(lngRow, Plan_Col).Row
Exit For
End If
Next lngRow
For lngRow = 2 To Cells(Rows.Count, 1).End(xlUp).Row - 1
If (Cells(lngRow, Plan_Col) = "77 Total") Then
Cells(lngRow, Over_30_Col).Formula = "=COUNTA(" & Range(Cells(row_73 + 1, Over_30_Col), Cells(lngRow - 1, Over_30_Col)).Address & ")"
Cells(lngRow, Over_30_Col).Formula = Application.ConvertFormula(Cells(lngRow, Over_30_Col).Formula, xlA1, xlA1, xlRelative)
Cells(lngRow, Over_30_Col).Copy Range(Cells(lngRow, Over_30_Col + 1), Cells(lngRow, Over_30_Col + 4))
Cells(lngRow, Over_30_Col + 3).Copy
Sheets("STATS").Range("G48").PasteSpecial Paste:=xlPasteValues
Cells(lngRow, Over_30_Col + 4).Copy
Sheets("STATS").Range("H48").PasteSpecial Paste:=xlPasteValues
Exit For
End If
Next lngRow
For lngRow = 2 To Cells(Rows.Count, 1).End(xlUp).Row - 1
If (Cells(lngRow, Plan_Col) = "77 Total") Then
row_77 = Cells(lngRow, Plan_Col).Row
Exit For
End If
Next lngRow
For lngRow = 2 To Cells(Rows.Count, 1).End(xlUp).Row - 1
If (Cells(lngRow, Plan_Col) = "78 Total") Then
Cells(lngRow, Over_30_Col).Formula = "=COUNTA(" & Range(Cells(row_77 + 1, Over_30_Col), Cells(lngRow - 1, Over_30_Col)).Address & ")"
Cells(lngRow, Over_30_Col).Formula = Application.ConvertFormula(Cells(lngRow, Over_30_Col).Formula, xlA1, xlA1, xlRelative)
Cells(lngRow, Over_30_Col).Copy Range(Cells(lngRow, Over_30_Col + 1), Cells(lngRow, Over_30_Col + 4))
Cells(lngRow, Over_30_Col + 3).Copy
Sheets("STATS").Range("G49").PasteSpecial Paste:=xlPasteValues
Cells(lngRow, Over_30_Col + 4).Copy
Sheets("STATS").Range("H49").PasteSpecial Paste:=xlPasteValues
Exit For
End If
Next lngRow
For lngRow = 2 To Cells(Rows.Count, 1).End(xlUp).Row - 1
If (Cells(lngRow, Plan_Col) = "78 Total") Then
row_78 = Cells(lngRow, Plan_Col).Row
Exit For
End If
Next lngRow
For lngRow = 2 To Cells(Rows.Count, 1).End(xlUp).Row - 1
If (Cells(lngRow, Plan_Col) = "92A Total") Then
Cells(lngRow, Over_30_Col).Formula = "=COUNTA(" & Range(Cells(row_78 + 1, Over_30_Col), Cells(lngRow - 1, Over_30_Col)).Address & ")"
Cells(lngRow, Over_30_Col).Formula = Application.ConvertFormula(Cells(lngRow, Over_30_Col).Formula, xlA1, xlA1, xlRelative)
Cells(lngRow, Over_30_Col).Copy Range(Cells(lngRow, Over_30_Col + 1), Cells(lngRow, Over_30_Col + 4))
Cells(lngRow, Over_30_Col + 3).Copy
Sheets("STATS").Range("G50").PasteSpecial Paste:=xlPasteValues
Cells(lngRow, Over_30_Col + 4).Copy
Sheets("STATS").Range("H50").PasteSpecial Paste:=xlPasteValues
Exit For
End If
Next lngRow
For lngRow = 2 To Cells(Rows.Count, 1).End(xlUp).Row - 1
If (Cells(lngRow, Plan_Col) = "92A Total") Then
row_92A = Cells(lngRow, Plan_Col).Row
Exit For
End If
Next lngRow
For lngRow = 2 To Cells(Rows.Count, 1).End(xlUp).Row - 1
If (Cells(lngRow, Plan_Col) = "92D Total") Then
Cells(lngRow, Over_30_Col).Formula = "=COUNTA(" & Range(Cells(row_92A + 1, Over_30_Col), Cells(lngRow - 1, Over_30_Col)).Address & ")"
Cells(lngRow, Over_30_Col).Formula = Application.ConvertFormula(Cells(lngRow, Over_30_Col).Formula, xlA1, xlA1, xlRelative)
Cells(lngRow, Over_30_Col).Copy Range(Cells(lngRow, Over_30_Col + 1), Cells(lngRow, Over_30_Col + 4))
Cells(lngRow, Over_30_Col + 3).Copy
Sheets("STATS").Range("G51").PasteSpecial Paste:=xlPasteValues
Cells(lngRow, Over_30_Col + 4).Copy
Sheets("STATS").Range("H51").PasteSpecial Paste:=xlPasteValues
Exit For
End If
Next lngRow
For lngRow = 2 To Cells(Rows.Count, 1).End(xlUp).Row - 1
If (Cells(lngRow, Plan_Col) = "92D Total") Then
row_92D = Cells(lngRow, Plan_Col).Row
Exit For
End If
Next lngRow
For lngRow = 2 To Cells(Rows.Count, 1).End(xlUp).Row - 1
If (Cells(lngRow, Plan_Col) = "92R Total") Then
Cells(lngRow, Over_30_Col).Formula = "=COUNTA(" & Range(Cells(row_92D + 1, Over_30_Col), Cells(lngRow - 1, Over_30_Col)).Address & ")"
Cells(lngRow, Over_30_Col).Formula = Application.ConvertFormula(Cells(lngRow, Over_30_Col).Formula, xlA1, xlA1, xlRelative)
Cells(lngRow, Over_30_Col).Copy Range(Cells(lngRow, Over_30_Col + 1), Cells(lngRow, Over_30_Col + 4))
Cells(lngRow, Over_30_Col + 3).Copy
Sheets("STATS").Range("G52").PasteSpecial Paste:=xlPasteValues
Cells(lngRow, Over_30_Col + 4).Copy
Sheets("STATS").Range("H52").PasteSpecial Paste:=xlPasteValues
Exit For
End If
Next lngRow
For lngRow = 2 To Cells(Rows.Count, 1).End(xlUp).Row - 1
If (Cells(lngRow, Plan_Col) = "92R Total") Then
row_92R = Cells(lngRow, Plan_Col).Row
Exit For
End If
Next lngRow
For lngRow = 2 To Cells(Rows.Count, 1).End(xlUp).Row - 1
If (Cells(lngRow, Plan_Col) = "92S Total") Then
Cells(lngRow, Over_30_Col).Formula = "=COUNTA(" & Range(Cells(row_92R + 1, Over_30_Col), Cells(lngRow - 1, Over_30_Col)).Address & ")"
Cells(lngRow, Over_30_Col).Formula = Application.ConvertFormula(Cells(lngRow, Over_30_Col).Formula, xlA1, xlA1, xlRelative)
Cells(lngRow, Over_30_Col).Copy Range(Cells(lngRow, Over_30_Col + 1), Cells(lngRow, Over_30_Col + 4))
Cells(lngRow, Over_30_Col + 3).Copy
Sheets("STATS").Range("G53").PasteSpecial Paste:=xlPasteValues
Cells(lngRow, Over_30_Col + 4).Copy
Sheets("STATS").Range("H53").PasteSpecial Paste:=xlPasteValues
Exit For
End If
Next lngRow
For lngRow = 2 To Cells(Rows.Count, 1).End(xlUp).Row - 1
If (Cells(lngRow, Plan_Col) = "92S Total") Then
row_92S = Cells(lngRow, Plan_Col).Row
Exit For
End If
Next lngRow
For lngRow = 2 To Cells(Rows.Count, 1).End(xlUp).Row - 1
If (Cells(lngRow, Plan_Col) = "92T Total") Then
Cells(lngRow, Over_30_Col).Formula = "=COUNTA(" & Range(Cells(row_92S + 1, Over_30_Col), Cells(lngRow - 1, Over_30_Col)).Address & ")"
Cells(lngRow, Over_30_Col).Formula = Application.ConvertFormula(Cells(lngRow, Over_30_Col).Formula, xlA1, xlA1, xlRelative)
Cells(lngRow, Over_30_Col).Copy Range(Cells(lngRow, Over_30_Col + 1), Cells(lngRow, Over_30_Col + 4))
Cells(lngRow, Over_30_Col + 3).Copy
Sheets("STATS").Range("G54").PasteSpecial Paste:=xlPasteValues
Cells(lngRow, Over_30_Col + 4).Copy
Sheets("STATS").Range("H54").PasteSpecial Paste:=xlPasteValues
Exit For
End If
Next lngRow
Sheets("STATS").Range("G55").Formula = "=SUM(G50:G54)"
Sheets("STATS").Range("H55").Formula = "=SUM(H50:H54)"
Sheets("STATS").Range("G56").Formula = "=SUM(G43:G49)+G55"
Sheets("STATS").Range("H56").Formula = "=SUM(H43:H49)+H55"