' MacroTB Macro
' Macro recorded 17/05/2007 by Wesfarmers Industrial & Safety
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.EnableEvents = False
Application.DisplayAlerts = False
ChDir "C:\Documents and Settings\AWP00\Desktop"
Workbooks.Open Filename:="C:\Documents and Settings\AWP00\Desktop\TB.csv"
Rows("1:10").Delete Shift:=xlUp
Cells.Select
Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
With Columns("A:B")
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlBottom
.ReadingOrder = xlContext
End With
Rows("1:1").Font.Bold = True
Columns("C:C").ColumnWidth = 25.43
Columns("A:A").ColumnWidth = 5.57
Columns("E:E").Delete Shift:=xlToLeft
Range("D1:N1").Value = Array("Terms", "Total", "Current", "Jan-30", "31-60 Days", "61-90 Days", "91-120 Days", "121-150 Days", "151+ Days", "Over 30", "Notes")
Columns("E:M").NumberFormat = "#,##0.00_ ;[Red]-#,##0.00 "
Columns("N:N").Select
Selection.InsertIndent 1
Range("C1") = "Customer Name"
With Range("E1:M1")
.HorizontalAlignment = xlRight
.ReadingOrder = xlContext
End With
ActiveWindow.DisplayZeros = False
Range("F1") = "1-30 day"
Range("A2").Select
ActiveWindow.FreezePanes = True
Sheets("TB").Name = "Original Data"
' CREATE NEW SHEET NAMED EXPORT AND FORMAT
Sheets.Add
ActiveSheet.Name = "Export"
Sheets("Original Data").Select
Range("A1:N1").Select
With Selection.Interior
.ColorIndex = 15
End With
Range("A1:N1").Copy
Sheets("Export").Select
ActiveSheet.Paste
Sheets("Original Data").Select
ActiveSheet.Paste
Range("M2") = "=SUM(RC[-4]:RC[-1])"
' Dim LR As Long, i As Long
LR = Range("E" & Rows.Count).End(xlUp).Row
For i = LR To 2 Step -1
With Range("E" & i)
If Not IsNumeric(.Value) Then .EntireRow.Delete
End With
Next i
' Dim LR As Long, i As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
For i = LR To 2 Step -1
With Range("A" & i)
If Not IsNumeric(.Value) Then .EntireRow.Delete
End With
Next i
' FILL DOWN FORMULA IN OVER 30 DAYS COLUMN
' New fill down formula
Range("M2").Formula = "=Sum(H2:L2)"
Range("M2").Copy Range("M2:M" & Cells(Rows.Count, 11).End(xlUp).Row - 1)
Range("A2").Select
Sheets("Export").Select
With ActiveSheet.PageSetup
.PrintTitleRows = ""
End With
ActiveSheet.PageSetup.PrintArea = ""
With ActiveSheet.PageSetup
.CenterHeader = "&""Arial,Bold""Export Trial Balance"
.LeftFooter = "Printed &D"
.RightFooter = "&P"
.LeftMargin = Application.InchesToPoints(0.354330708661417)
.RightMargin = Application.InchesToPoints(0.354330708661417)
.TopMargin = Application.InchesToPoints(0.984251968503937)
.BottomMargin = Application.InchesToPoints(0.984251968503937)
.HeaderMargin = Application.InchesToPoints(0.511811023622047)
.FooterMargin = Application.InchesToPoints(0.511811023622047)
.PrintGridlines = True
.CenterHorizontally = True
.Orientation = xlLandscape
End With
Sheets("Original Data").Select
ActiveSheet.PageSetup.PrintArea = ""
With ActiveSheet.PageSetup
.CenterHeader = "&""Arial,Bold""Trial Balance - Original Data"
.LeftFooter = "Printed &D"
.RightFooter = "&P"
.LeftMargin = Application.InchesToPoints(0.748031496062992)
.RightMargin = Application.InchesToPoints(0.748031496062992)
.TopMargin = Application.InchesToPoints(0.984251968503937)
.BottomMargin = Application.InchesToPoints(0.984251968503937)
.HeaderMargin = Application.InchesToPoints(0.511811023622047)
.FooterMargin = Application.InchesToPoints(0.511811023622047)
.PrintGridlines = True
.CenterHorizontally = True
.Orientation = xlLandscape
End With
Range("A3").Select
With Columns("D:D")
.ColumnWidth = 5.1
.HorizontalAlignment = xlCenter
.ReadingOrder = xlContext
End With
Columns("B:B").NumberFormat = "000000"
Columns("D:D").Insert Shift:=xlToRight
' PROPER FORMULA ON NAMES AND FILL DOWN
Range("D2") = "=PROPER(RC[-1])"
ActiveCell.Offset(0, 1).Select
Selection.End(xlDown).Select
ActiveCell.Offset(0, -1).Range("A1").Select
ActiveCell.FormulaR1C1 = "x"
Selection.End(xlUp).Select
Selection.Copy
Range(Selection, Selection.End(xlDown)).Select
ActiveSheet.Paste
Range("C1").Select
Selection.Cut Destination:=Range("D1")
Columns("D:D").Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveSheet.Paste
Application.CutCopyMode = False
Columns("C:C").Delete Shift:=xlToLeft
Columns("C:C").ColumnWidth = 21.29
Columns("D:D").ColumnWidth = 5.1
' PUT MONTHS MS COLUMN HEADINGS
Dim lRow As Long 'Row you want information to be on
' Dim lCol As Long
Dim lIncrement As Long
Dim lStart As Long 'Column you want to start in
Dim lEnd As Long 'Column you want to end with
lIncrement = -1 'Starting increment
lRow = 1
lStart = 6
lEnd = 12
' Formats range so the date will appear in the needed format mmm = Jan,
' mmm yy = Jan 07, mmm yyyy = Jan 2007
Range(Cells(lRow, lStart), Cells(lRow, lEnd)).NumberFormat = "mmm"
' This loop fills in the header values base on today's date. Each column is
' advanced based on the incrementation set in lIncrement
For lCol = lStart To lEnd
ActiveSheet.Cells(lRow, lCol).Value = DateAdd("m", lIncrement, Date)
lIncrement = lIncrement - 1
Next lCol
' FORMATTING ON EXPORT SHEET
Sheets("Export").Select
Columns("C:C").ColumnWidth = 21.29
Columns("E:E").ColumnWidth = 12.57
Columns("D:D").ColumnWidth = 5.14
Columns("F:H").ColumnWidth = 11.43
Columns("I:L").ColumnWidth = 10.57
Columns("M:M").ColumnWidth = 12.71
Columns("N:N").ColumnWidth = 40.57
With Range("D1:K1")
.HorizontalAlignment = xlRight
.ReadingOrder = xlContext
End With
Columns("D:D").Select
With Selection
.HorizontalAlignment = xlCenter
.ReadingOrder = xlContext
End With
Columns("A:A").EntireColumn.Hidden = True
Columns("E:M").NumberFormat = "#,##0.00"
Range("B2").Select
ActiveWindow.DisplayZeros = False
ActiveWindow.FreezePanes = True
' COPY HEADINGS FROM ORIGINAL DATA TO EXPORT
Sheets("Export").Select
Range("E1:K1").NumberFormat = "@"
Sheets("Original Data").Select
Range("D1:N1").Copy
Sheets("Export").Select
Range("D1").Select
ActiveSheet.Paste
Range("A2").Select
' ADD EXTRA SHEETS FOR EACH LEDGER
' These sheets are copied from Export tab so that formatting is correct.
Sheets("Export").Copy After:=Sheets(2)
Sheets("Export (2)").Copy After:=Sheets(3)
Sheets("Export (3)").Copy After:=Sheets(4)
Sheets("Export (4)").Copy After:=Sheets(5)
Sheets("Export (5)").Copy After:=Sheets(6)
Sheets("Export (6)").Copy After:=Sheets(7)
Sheets("Export (7)").Copy After:=Sheets(8)
Sheets("Export (8)").Copy After:=Sheets(9)
Sheets("Export (9)").Copy After:=Sheets(10)
Sheets("Export (10)").Copy After:=Sheets(11)
Sheets("Export (11)").Copy After:=Sheets(12)
Sheets("Export (2)").Name = "Spare"
Sheets("Export (3)").Name = "VL"
Sheets("Export (4)").Name = "DW"
Sheets("Export (5)").Name = "HH"
Sheets("Export (6)").Name = "HS"
Sheets("Export (7)").Name = "ML"
Sheets("Export (8)").Name = "MGMT"
Sheets("Export (9)").Name = "MS"
Sheets("Export (10)").Name = "RC"
Sheets("Export (11)").Name = "PG"
Sheets("Export (12)").Name = "CM"
' RENAME EACH SHEET
Sheets("Spare").Select
With ActiveSheet.PageSetup
.PrintTitleRows = "$1:$1"
End With
ActiveSheet.PageSetup.PrintArea = ""
With ActiveSheet.PageSetup
.CenterHeader = "&""Arial,Bold""Trial Balance Spare (8067 7201)"
End With
Sheets("PG").Select
With ActiveSheet.PageSetup
.PrintTitleRows = "$1:$1"
End With
ActiveSheet.PageSetup.PrintArea = ""
With ActiveSheet.PageSetup
.CenterHeader = "&""Arial,Bold""Trial Balance Pauline (8110 7202)"
End With
Sheets("DW").Select
With ActiveSheet.PageSetup
.PrintTitleRows = "$1:$1"
End With
ActiveSheet.PageSetup.PrintArea = ""
With ActiveSheet.PageSetup
.CenterHeader = "&""Arial,Bold""Trial Balance Danielle (8113 7203)"
End With
Sheets("HH").Select
With ActiveSheet.PageSetup
.PrintTitleRows = "$1:$1"
End With
ActiveSheet.PageSetup.PrintArea = ""
With ActiveSheet.PageSetup
.CenterHeader = "Trial Balance Heidi (8116 7204)"
End With
Sheets("HS").Select
With ActiveSheet.PageSetup
.PrintTitleRows = "$1:$1"
End With
ActiveSheet.PageSetup.PrintArea = ""
With ActiveSheet.PageSetup
.CenterHeader = "&""Arial,Bold""Trial Balance Harbans (8068 7065)"
End With
Sheets("ML").Select
With ActiveSheet.PageSetup
.PrintTitleRows = "$1:$1"
End With
ActiveSheet.PageSetup.PrintArea = ""
With ActiveSheet.PageSetup
.CenterHeader = "&""Arial,Bold""Trial Balance Marme (8112 7221)"
End With
Sheets("MGMT").Select
With ActiveSheet.PageSetup
.PrintTitleRows = "$1:$1"
End With
ActiveSheet.PageSetup.PrintArea = ""
With ActiveSheet.PageSetup
.CenterHeader = "&""Arial,Bold""Trial Balance Management Accounts"
End With
Sheets("MS").Select
With ActiveSheet.PageSetup
.PrintTitleRows = "$1:$1"
End With
ActiveSheet.PageSetup.PrintArea = ""
With ActiveSheet.PageSetup
.CenterHeader = "&""Arial,Bold""Trial Balance Mandeep (8201 7220)"
End With
Sheets("RC").Select
With ActiveSheet.PageSetup
.PrintTitleRows = "$1:$1"
End With
ActiveSheet.PageSetup.PrintArea = ""
With ActiveSheet.PageSetup
.CenterHeader = "&""Arial,Bold""Trial Balance Rosemary (8202 7222 Buying Group Members, 8204 7223 The Rest)"
End With
Sheets("VL").Select
With ActiveSheet.PageSetup
.PrintTitleRows = "$1:$1"
End With
ActiveSheet.PageSetup.PrintArea = ""
With ActiveSheet.PageSetup
.CenterHeader = "&""Arial,Bold""Trial Balance Vannessa (8203 7066)"
End With
Sheets("CM").Select
With ActiveSheet.PageSetup
.PrintTitleRows = "$1:$1"
End With
ActiveSheet.PageSetup.PrintArea = ""
With ActiveSheet.PageSetup
.CenterHeader = "&""Arial,Bold""Trial Balance Carissa (7067 8108)"
End With
' COPY & PASTE 7064 & 8064 TO EXPORT SHEET
Dim wsSht1 As Worksheet
Dim wssht2 As Worksheet
Dim lRowSht2 As Long
Dim llastrow As Long
Dim sCustCode As String
Set wsSht1 = Sheets("Original Data")
Set wssht2 = Sheets("Export")
llastrow = wsSht1.Cells(wsSht1.Rows.Count, "a").End(xlUp).Row
lRowSht2 = 2
For lRow = 1 To llastrow
sCustCode = wsSht1.Cells(lRow, 1).Value
If sCustCode = "7064" Or sCustCode = "8064" Then
wsSht1.Rows(lRow).EntireRow.Copy Destination:=wssht2.Cells(lRowSht2, 1)
lRowSht2 = lRowSht2 + 1
End If
Next lRow
' TOTAL AT THE BOTTOM OF EXPORT SHEET IN BOLD
Sheets("Export").Select
Range("D1").Select
Range("D65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.Font.Bold = True
Selection.Font.ColorIndex = 5
Range("E1").Select
Range("E65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.Font.Bold = True
Selection.Font.ColorIndex = 5
Range("F1").Select
Range("F65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.Font.Bold = True
Selection.Font.ColorIndex = 5
Range("G1").Select
Range("G65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.Font.Bold = True
Selection.Font.ColorIndex = 5
Range("H1").Select
Range("H65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.Font.Bold = True
Selection.Font.ColorIndex = 5
Range("I1").Select
Range("I65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.Font.Bold = True
Selection.Font.ColorIndex = 5
Range("J1").Select
Range("J65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.Font.Bold = True
Selection.Font.ColorIndex = 5
Range("K1").Select
Range("K65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.Font.Bold = True
Selection.Font.ColorIndex = 5
Cells.Select
Range("B1").Activate
Selection.Sort Key1:=Range("L2"), Order1:=xlDescending, Key2:=Range("C2") _
, Order2:=xlAscending, Key3:=Range("B2"), Order3:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, DataOption3:= _
xlSortNormal
Range("B2").Select
' PAGE SET UP FORMATING
With ActiveSheet.PageSetup
.PrintTitleRows = "$1:$1"
End With
ActiveSheet.PageSetup.PrintArea = ""
With ActiveSheet.PageSetup
.CenterHeader = "&""Arial,Bold""Trial Balance - Export"
.LeftFooter = "Printed &D"
.RightFooter = "&P"
.LeftMargin = Application.InchesToPoints(0.354330708661417)
.RightMargin = Application.InchesToPoints(0.354330708661417)
.TopMargin = Application.InchesToPoints(1)
.BottomMargin = Application.InchesToPoints(1)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintGridlines = True
.CenterHorizontally = True
.Orientation = xlLandscape
End With
' COPY & PASTE 8067 & 7201 TO Spare SHEET
Set wsSht1 = Sheets("Original Data")
Set wssht2 = Sheets("Spare")
llastrow = wsSht1.Cells(wsSht1.Rows.Count, "a").End(xlUp).Row
lRowSht2 = 2
For lRow = 1 To llastrow
sCustCode = wsSht1.Cells(lRow, 1).Value
If sCustCode = "8067" Or sCustCode = "7201" Then
wsSht1.Rows(lRow).EntireRow.Copy Destination:=wssht2.Cells(lRowSht2, 1)
lRowSht2 = lRowSht2 + 1
End If
Next lRow
' PUT TOTALS AT THE BOTTOM OF Spare SHEET IN BOLD
Sheets("Spare").Select
Range("D1").Select
Range("D65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("E1").Select
Range("E65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("F1").Select
Range("F65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("G1").Select
Range("G65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("H1").Select
Range("H65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("I1").Select
Range("I65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("J1").Select
Range("J65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("K1").Select
Range("K65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Cells.Select
Range("B1").Activate
Selection.Sort Key1:=Range("L2"), Order1:=xlDescending, Key2:=Range("C2") _
, Order2:=xlAscending, Key3:=Range("B2"), Order3:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, DataOption3:= _
xlSortNormal
' COPY & PASTE 8110 & 7202 TO PG SHEET
Set wsSht1 = Sheets("Original Data")
Set wssht2 = Sheets("PG")
llastrow = wsSht1.Cells(wsSht1.Rows.Count, "a").End(xlUp).Row
lRowSht2 = 2
For lRow = 1 To llastrow
sCustCode = wsSht1.Cells(lRow, 1).Value
If sCustCode = "8110" Or sCustCode = "7202" Then
wsSht1.Rows(lRow).EntireRow.Copy Destination:=wssht2.Cells(lRowSht2, 1)
lRowSht2 = lRowSht2 + 1
End If
Next lRow
' PUT TOTALS AT THE BOTTOM OF A SHEET IN BOLD
Sheets("PG").Select
Range("D1").Select
Range("D65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("E1").Select
Range("E65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("F1").Select
Range("F65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("G1").Select
Range("G65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("H1").Select
Range("H65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("I1").Select
Range("I65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("J1").Select
Range("J65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("K1").Select
Range("K65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Cells.Select
Range("B1").Activate
Selection.Sort Key1:=Range("L2"), Order1:=xlDescending, Key2:=Range("C2") _
, Order2:=xlAscending, Key3:=Range("B2"), Order3:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, DataOption3:= _
xlSortNormal
' COPY & PASTE 8113 & 7203 TO DW SHEET
Set wsSht1 = Sheets("Original Data")
Set wssht2 = Sheets("DW")
llastrow = wsSht1.Cells(wsSht1.Rows.Count, "a").End(xlUp).Row
lRowSht2 = 2
For lRow = 1 To llastrow
sCustCode = wsSht1.Cells(lRow, 1).Value
If sCustCode = "8113" Or sCustCode = "7203" Then
wsSht1.Rows(lRow).EntireRow.Copy Destination:=wssht2.Cells(lRowSht2, 1)
lRowSht2 = lRowSht2 + 1
End If
Next lRow
' PUT TOTALS AT THE BOTTOM OF DW SHEET IN BOLD
Sheets("DW").Select
Range("D1").Select
Range("D65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("E1").Select
Range("E65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("F1").Select
Range("F65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("G1").Select
Range("G65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("H1").Select
Range("H65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("I1").Select
Range("I65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("J1").Select
Range("J65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("K1").Select
Range("K65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Cells.Select
Range("B1").Activate
Selection.Sort Key1:=Range("L2"), Order1:=xlDescending, Key2:=Range("C2") _
, Order2:=xlAscending, Key3:=Range("B2"), Order3:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, DataOption3:= _
xlSortNormal
Range("B2").Select
' COPY & PASTE 8116 & 7204 TO HH SHEET
Set wsSht1 = Sheets("Original Data")
Set wssht2 = Sheets("HH")
llastrow = wsSht1.Cells(wsSht1.Rows.Count, "a").End(xlUp).Row
lRowSht2 = 2
For lRow = 1 To llastrow
sCustCode = wsSht1.Cells(lRow, 1).Value
If sCustCode = "8116" Or sCustCode = "7204" Then
wsSht1.Rows(lRow).EntireRow.Copy Destination:=wssht2.Cells(lRowSht2, 1)
lRowSht2 = lRowSht2 + 1
End If
Next lRow
' PUT TOTALS AT THE BOTTOM OF HH SHEET IN BOLD
' ============================================
Sheets("HH").Select
Range("D1").Select
Range("D65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("E1").Select
Range("E65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("F1").Select
Range("F65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("G1").Select
Range("G65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("H1").Select
Range("H65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("I1").Select
Range("I65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("J1").Select
Range("J65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("K1").Select
Range("K65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Cells.Select
Range("B1").Activate
Selection.Sort Key1:=Range("L2"), Order1:=xlDescending, Key2:=Range("C2") _
, Order2:=xlAscending, Key3:=Range("B2"), Order3:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, DataOption3:= _
xlSortNormal
' COPY & PASTE 8068 & 7065 TO HS SHEET
Set wsSht1 = Sheets("Original Data")
Set wssht2 = Sheets("HS")
llastrow = wsSht1.Cells(wsSht1.Rows.Count, "a").End(xlUp).Row
lRowSht2 = 2
For lRow = 1 To llastrow
sCustCode = wsSht1.Cells(lRow, 1).Value
If sCustCode = "8068" Or sCustCode = "7065" Then
wsSht1.Rows(lRow).EntireRow.Copy Destination:=wssht2.Cells(lRowSht2, 1)
lRowSht2 = lRowSht2 + 1
End If
Next lRow
' PUT TOTALS AT THE BOTTOM OF HS SHEET IN BOLD
Sheets("HS").Select
Range("D1").Select
Range("D65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Selection.Font.ColorIndex = 5
Range("E1").Select
Range("E65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Selection.Font.ColorIndex = 5
Range("F1").Select
Range("F65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Selection.Font.ColorIndex = 5
Range("G1").Select
Range("G65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Selection.Font.ColorIndex = 5
Range("H1").Select
Range("H65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Selection.Font.ColorIndex = 5
Range("I1").Select
Range("I65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Selection.Font.ColorIndex = 5
Range("J1").Select
Range("J65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Selection.Font.ColorIndex = 5
Range("K1").Select
Range("K65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Selection.Font.ColorIndex = 5
Cells.Select
Range("B1").Activate
Selection.Sort Key1:=Range("L2"), Order1:=xlDescending, Key2:=Range("C2") _
, Order2:=xlAscending, Key3:=Range("B2"), Order3:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, DataOption3:= _
xlSortNormal
' COPY & PASTE 8112 & 7221 TO ML SHEET
Set wsSht1 = Sheets("Original Data")
Set wssht2 = Sheets("ML")
llastrow = wsSht1.Cells(wsSht1.Rows.Count, "a").End(xlUp).Row
lRowSht2 = 2
For lRow = 1 To llastrow
sCustCode = wsSht1.Cells(lRow, 1).Value
If sCustCode = "8112" Or sCustCode = "7221" Then
wsSht1.Rows(lRow).EntireRow.Copy Destination:=wssht2.Cells(lRowSht2, 1)
lRowSht2 = lRowSht2 + 1
End If
Next lRow
' PUT TOTALS AT THE BOTTOM OF ML SHEET IN BOLD
Sheets("ML").Select
Range("D1").Select
Range("D65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("E1").Select
Range("E65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("F1").Select
Range("F65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("G1").Select
Range("G65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("H1").Select
Range("H65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("I1").Select
Range("I65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("J1").Select
Range("J65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("K1").Select
Range("K65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Cells.Select
Range("B1").Activate
Selection.Sort Key1:=Range("L2"), Order1:=xlDescending, Key2:=Range("C2") _
, Order2:=xlAscending, Key3:=Range("B2"), Order3:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, DataOption3:= _
xlSortNormal
' COPY & PASTE 8900 & 7998 TO MGMT SHEET
Set wsSht1 = Sheets("Original Data")
Set wssht2 = Sheets("MGMT")
llastrow = wsSht1.Cells(wsSht1.Rows.Count, "a").End(xlUp).Row
lRowSht2 = 2
For lRow = 1 To llastrow
sCustCode = wsSht1.Cells(lRow, 1).Value
If sCustCode = "8900" Or sCustCode = "7998" Then
wsSht1.Rows(lRow).EntireRow.Copy Destination:=wssht2.Cells(lRowSht2, 1)
lRowSht2 = lRowSht2 + 1
End If
Next lRow
' PUT TOTALS AT THE BOTTOM OF MGMT SHEET IN BOLD
Sheets("MGMT").Select
Range("D1").Select
Range("D65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Selection.Font.ColorIndex = 5
Range("E1").Select
Range("E65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Selection.Font.ColorIndex = 5
Range("F1").Select
Range("F65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Selection.Font.ColorIndex = 5
Range("G1").Select
Range("G65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Selection.Font.ColorIndex = 5
Range("H1").Select
Range("H65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Selection.Font.ColorIndex = 5
Range("I1").Select
Range("I65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Selection.Font.ColorIndex = 5
Range("J1").Select
Range("J65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Selection.Font.ColorIndex = 5
Range("K1").Select
Range("K65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Selection.Font.ColorIndex = 5
Range("L1").Select
Range("L65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Selection.Font.ColorIndex = 5
Cells.Select
Range("B1").Activate
Selection.Sort Key1:=Range("L2"), Order1:=xlDescending, Key2:=Range("C2") _
, Order2:=xlAscending, Key3:=Range("B2"), Order3:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, DataOption3:= _
xlSortNormal
Range("B2").Select
' COPY & PASTE 8201 & 7220 TO MS SHEET
Set wsSht1 = Sheets("Original Data")
Set wssht2 = Sheets("MS")
llastrow = wsSht1.Cells(wsSht1.Rows.Count, "a").End(xlUp).Row
lRowSht2 = 2
For lRow = 1 To llastrow
sCustCode = wsSht1.Cells(lRow, 1).Value
If sCustCode = "8201" Or sCustCode = "7220" Then
wsSht1.Rows(lRow).EntireRow.Copy Destination:=wssht2.Cells(lRowSht2, 1)
lRowSht2 = lRowSht2 + 1
End If
Next lRow
' PUT TOTALS AT THE BOTTOM OF MS SHEET IN BOLD
Sheets("MS").Select
Range("D1").Select
Range("D65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("E1").Select
Range("E65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("F1").Select
Range("F65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("G1").Select
Range("G65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("H1").Select
Range("H65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("I1").Select
Range("I65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("J1").Select
Range("J65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("K1").Select
Range("K65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Cells.Select
Range("B1").Activate
Selection.Sort Key1:=Range("L2"), Order1:=xlDescending, Key2:=Range("C2") _
, Order2:=xlAscending, Key3:=Range("B2"), Order3:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, DataOption3:= _
xlSortNormal
' COPY & PASTE 8202, 7222, 8204 & 7223 TO RC SHEET
Set wsSht1 = Sheets("Original Data")
Set wssht2 = Sheets("RC")
llastrow = wsSht1.Cells(wsSht1.Rows.Count, "a").End(xlUp).Row
lRowSht2 = 2
For lRow = 1 To llastrow
sCustCode = wsSht1.Cells(lRow, 1).Value
If sCustCode = "8204" Or sCustCode = "7223" Or sCustCode = "7222" Or sCustCode = "8202" Then
wsSht1.Rows(lRow).EntireRow.Copy Destination:=wssht2.Cells(lRowSht2, 1)
lRowSht2 = lRowSht2 + 1
End If
Next lRow
' PUT TOTALS AT THE BOTTOM OF RC SHEET IN BOLD
Sheets("RC").Select
Range("D1").Select
Range("D65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Selection.Font.ColorIndex = 5
Range("E1").Select
Range("E65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Selection.Font.ColorIndex = 5
Range("F1").Select
Range("F65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Selection.Font.ColorIndex = 5
Range("G1").Select
Range("G65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Selection.Font.ColorIndex = 5
Range("H1").Select
Range("H65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Selection.Font.ColorIndex = 5
Range("I1").Select
Range("I65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Selection.Font.ColorIndex = 5
Range("J1").Select
Range("J65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Selection.Font.ColorIndex = 5
Range("K1").Select
Range("K65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Selection.Font.ColorIndex = 5
Cells.Select
Range("B1").Activate
Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Key2:=Range("C2") _
, Order2:=xlAscending, Key3:=Range("B2"), Order3:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, DataOption3:= _
xlSortNormal
' COPY & PASTE 8203 & 7066 TO VL SHEET
Set wsSht1 = Sheets("Original Data")
Set wssht2 = Sheets("VL")
llastrow = wsSht1.Cells(wsSht1.Rows.Count, "a").End(xlUp).Row
lRowSht2 = 2
For lRow = 1 To llastrow
sCustCode = wsSht1.Cells(lRow, 1).Value
If sCustCode = "8203" Or sCustCode = "7061" Then
wsSht1.Rows(lRow).EntireRow.Copy Destination:=wssht2.Cells(lRowSht2, 1)
lRowSht2 = lRowSht2 + 1
End If
Next lRow
' PUT TOTALS AT THE BOTTOM OF VL SHEET IN BOLD
Sheets("VL").Select
Range("D1").Select
Range("D65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Selection.Font.ColorIndex = 5
Range("E1").Select
Range("E65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Selection.Font.ColorIndex = 5
Range("F1").Select
Range("F65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Selection.Font.ColorIndex = 5
Range("G1").Select
Range("G65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Selection.Font.ColorIndex = 5
Range("H1").Select
Range("H65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Selection.Font.ColorIndex = 5
Range("I1").Select
Range("I65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Selection.Font.ColorIndex = 5
Range("J1").Select
Range("J65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Selection.Font.ColorIndex = 5
Range("K1").Select
Range("K65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Selection.Font.ColorIndex = 5
Cells.Select
Range("B1").Activate
Selection.Sort Key1:=Range("L2"), Order1:=xlDescending, Key2:=Range("C2") _
, Order2:=xlAscending, Key3:=Range("B2"), Order3:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, DataOption3:= _
xlSortNormal
' COPY & PASTE 8108 & 7067 TO CM SHEET
Set wsSht1 = Sheets("Original Data")
Set wssht2 = Sheets("CM")
llastrow = wsSht1.Cells(wsSht1.Rows.Count, "a").End(xlUp).Row
lRowSht2 = 2
For lRow = 1 To llastrow
sCustCode = wsSht1.Cells(lRow, 1).Value
If sCustCode = "8108" Or sCustCode = "7067" Then
wsSht1.Rows(lRow).EntireRow.Copy Destination:=wssht2.Cells(lRowSht2, 1)
lRowSht2 = lRowSht2 + 1
End If
Next lRow
' PUT TOTALS AT THE BOTTOM OF CM SHEET IN BOLD
Sheets("CM").Select
Range("D1").Select
Range("D65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("E1").Select
Range("E65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("F1").Select
Range("F65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("G1").Select
Range("G65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("H1").Select
Range("H65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("I1").Select
Range("I65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("J1").Select
Range("J65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Range("K1").Select
Range("K65536").End(xlUp).Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = "=SUM(R[" & -ActiveCell.Row + 2 & "]C:R[-1]C)"
Selection.NumberFormat = "#,##0.00_);[Red](#,##0.00)"
Selection.Font.Bold = True
Cells.Select
Range("B1").Activate
Selection.Sort Key1:=Range("L2"), Order1:=xlDescending, Key2:=Range("C2") _
, Order2:=xlAscending, Key3:=Range("B2"), Order3:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, DataOption3:= _
xlSortNormal
Range("B2").Select
' END OF COPYING AND PASTING ACCTS INTO COLLECTORS TABS
Sheets("Export").Select
Sheets("Export").Move Before:=Sheets(3)
Sheets("Original Data").Select
' COLOURED TABS
Sheets("CM").Tab.ColorIndex = 53
Sheets("VL").Tab.ColorIndex = 16
Sheets("RC").Tab.ColorIndex = 7
Sheets("MS").Tab.ColorIndex = 44
Sheets("MGMT").Tab.ColorIndex = 43
Sheets("ML").Tab.ColorIndex = 5
Sheets("HS").Tab.ColorIndex = 3
Sheets("HH").Tab.ColorIndex = 54
Sheets("DW").Tab.ColorIndex = 46
Sheets("PG").Tab.ColorIndex = 1
Sheets("Spare").Tab.ColorIndex = 6
Sheets("Export").Tab.ColorIndex = 14
Sheets("Original Data").Tab.ColorIndex = 9
' Rosemary
Sheets("RC").Select
Range("A1:N1").Interior.ColorIndex = 50
Rows("1:1").Font.ColorIndex = 13
' Unhide column A
Columns("A:A").ColumnWidth = 6.1
ActiveWindow.FreezePanes = False
Range("D2").Select
ActiveWindow.FreezePanes = True
' Harbans
Sheets("HS").Select
Range("B1:N1").Interior.ColorIndex = 3
Rows("1:1").Font.ColorIndex = 2
' Marme
Sheets("ML").Select
With Range("B1:N1")
.Font.ColorIndex = 5
.ColorIndex = 3
End With
ActiveWindow.FreezePanes = False
Range("D2").Select
ActiveWindow.FreezePanes = True
' Spare
Sheets("Spare").Select
With Range("B1:N1")
.Interior.ColorIndex = 5
.Font.ColorIndex = 6
End With
' Vannessa
Sheets("VL").Select
With Range("B1:N1")
.Interior.ColorIndex = 16
.Font.ColorIndex = 2
End With
' Heidi
Sheets("HH").Select
Range("B1:N1").Interior.ColorIndex = 6
ActiveWindow.FreezePanes = False
Range("D2").Select
ActiveWindow.FreezePanes = True
' Pauline
Sheets("PG").Select
With Range("B1:N1")
.Font.ColorIndex = 2
.Interior.ColorIndex = 1
End With
' Carrisa
Sheets("CM").Select
Range ("B1:N1")
.Font.ColorIndex = 5
.Interior.ColorIndex = 3
End With
' Danielle
Sheets("DW").Select
With Range("B1:N1")
.Font.ColorIndex = 38
.Interior.ColorIndex = 3
End With
' Spare TAB INACTIVE. DELETE FROM FINISHED REPORT
' If a new collector is needed this tab can be reistated by removing the delete
' sheet code below and renaming the tab.
Sheets("Spare").Select
ActiveWindow.SelectedSheets.Delete
Sheets("Original Data").Select
Range("A4").Select
ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\AWP00\Desktop\TB.xlsx", FileFormat:=xlOpenXMLWorkbook, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True
Application.DisplayAlerts = True
End Sub