Visual Basic-Work Spreadsheet
Visual Basic-Work Spreadsheet
Visual Basic-Work Spreadsheet
Sub Clean_Up_Report()
With sourceSheet
SourceLastRow = .Cells(.Rows.Count, "K").End(xlUp).Row
End With
With sourceSheet
SourceLastColumn = .Cells(.Columns.Count, "K").End(xlUp).Column
End With
With sourceSheet1
SourceLastRow1 = .Cells(.Rows.Count, "J").End(xlUp).Row
End With
With sourceSheet1
SourceLastColumn1 = .Cells(.Columns.Count, "J").End(xlUp).Column
End With
With sourceSheet2
SourceLastRow2 = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
With sourceSheet2
SourceLastColumn2 = .Cells(.Columns.Count, "A").End(xlUp).Column
End With
With sourceSheet3
SourceLastRow3 = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
With sourceSheet3
SourceLastColumn3 = .Cells(.Columns.Count, "A").End(xlUp).Column
End With
With sourceSheet4
SourceLastRow4 = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
With sourceSheet4
SourceLastColumn4 = .Cells(.Columns.Count, "A").End(xlUp).Column
End With
Module1 - 2
End With
'Part II
With outputSheet
OutputLastRow = .Cells(Rows.Count, "A").End(xlUp).Row
.Range("D12:D" & OutputLastRow).Formula = _
"=IF($AY12=$AZ$12,$BA$12,IF($AY12=$AZ$13,$BA$13,IF($AY12=$AZ$14,$BA$14,IF($AY12=$AZ$15,$BA$15,
IF($AY12=$AZ$16,$BA$16,IF($AY12=$AZ$17,$BA$17,""""))))))"
End With
'MONTHLY SUMMARIES
With outputSheet
OutputLastRow = .Cells(.Rows.Count, "F").End(xlUp).Row
.Range("S12:S" & OutputLastRow).Formula = _
"=SUMPRODUCT(('" & sourceSheet1.Name & "'!$I$13:$I$" & SourceLastRow1 & ")*('" & sourceShe
et1.Name & "'!D$13:D$" & SourceLastRow1 & "=$S$10)*('" & sourceSheet1.Name & "'!A$13:A$" & SourceLastR
ow1 & "=$A12)*('" & sourceSheet1.Name & "'!C$13:C$" & SourceLastRow1 & "=$C12)*('" & sourceSheet1.Name
& "'!E$13:E$" & SourceLastRow1 & "=$F12))"
End With
'Sum for Month of November
With outputSheet
OutputLastRow = .Cells(.Rows.Count, "F").End(xlUp).Row
.Range("T12:T" & OutputLastRow).Formula = _
"=SUMPRODUCT(('" & sourceSheet1.Name & "'!$I$13:$I$" & SourceLastRow1 & ")*('" & sourceShe
et1.Name & "'!D$13:D$" & SourceLastRow1 & "=$T$10)*('" & sourceSheet1.Name & "'!A$13:A$" & SourceLastR
ow1 & "=$A12)*('" & sourceSheet1.Name & "'!C$13:C$" & SourceLastRow1 & "=$C12)*('" & sourceSheet1.Name
& "'!E$13:E$" & SourceLastRow1 & "=$F12))"
End With
'Sum for Month of December
With outputSheet
OutputLastRow = .Cells(.Rows.Count, "F").End(xlUp).Row
.Range("U12:U" & OutputLastRow).Formula = _
"=SUMPRODUCT(('" & sourceSheet1.Name & "'!$I$13:$I$" & SourceLastRow1 & ")*('" & sourceShe
et1.Name & "'!D$13:D$" & SourceLastRow1 & "=$U$10)*('" & sourceSheet1.Name & "'!A$13:A$" & SourceLastR
ow1 & "=$A12)*('" & sourceSheet1.Name & "'!C$13:C$" & SourceLastRow1 & "=$C12)*('" & sourceSheet1.Name
& "'!E$13:E$" & SourceLastRow1 & "=$F12))"
End With
'FromTo Brand ID
With outputSheet
OutputLastRow = .Cells(.Rows.Count, "F").End(xlUp).Row
.Range("AC12:AC" & OutputLastRow).Formula = _
"=VLOOKUP(Z12,'" & sourceSheet2.Name & "'!$F$3:$I$" & SourceLastRow2 & ",3,FALSE)"
End With
'Proprietary Status
With outputSheet
OutputLastRow = .Cells(.Rows.Count, "F").End(xlUp).Row
.Range("AE12:AE" & OutputLastRow).Formula = _
"=VLOOKUP(F12,'" & sourceSheet3.Name & "'!$C$2:$K$" & SourceLastRow3 & ",9,FALSE)"
End With
'Sector
With outputSheet
OutputLastRow = .Cells(.Rows.Count, "F").End(xlUp).Row
.Range("X12:X" & OutputLastRow).Formula = _
"=IF($D12="""","""",$D12)"
End With
'Order Guide
With outputSheet
OutputLastRow = .Cells(.Rows.Count, "F").End(xlUp).Row
.Range("Y12:Y" & OutputLastRow).Formula = _
"=IF($E12="""","""",$E12)"
End With
'Stocking Status
With outputSheet
OutputLastRow = .Cells(.Rows.Count, "F").End(xlUp).Row
.Range("AD12:AD" & OutputLastRow).Formula = _
"=INDEX('" & sourceSheet4.Name & "'!I$2:I$" & SourceLastRow4 & ",MATCH(1,INDEX((A12='" & sourc
eSheet4.Name & "'!A$2:A$" & SourceLastRow4 & ")*(Z12='" & sourceSheet4.Name & "'!B$2:B$" & SourceLastR
ow4 & "),0,1),0),1)"
End With
'Pack / Size
With outputSheet
OutputLastRow = .Cells(.Rows.Count, "F").End(xlUp).Row
.Range("AB12:AB" & OutputLastRow).Formula = _
"=IFERROR(VLOOKUP(Z12,'" & sourceSheet1.Name & "'!$E$3:$G$" & SourceLastRow1 & ",3,FALSE),""""
)"
End With
'Calculation Formulas
'Sum Case Quantity
With outputSheet
OutputLastRow = .Cells(.Rows.Count, "F").End(xlUp).Row
.Range("V12:V" & OutputLastRow).Formula = _
"=IF(SUM($J12:$U12)="""","""",SUM($J12:$U12))"
End With
End Sub