Sub a()
'
'Initial Setup
Workbooks.OpenText Filename:= _
"\\Cisora12\it-windev_dscranton\pd296\1\PD296.prt", Origin:=437, StartRow:= _
1, DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 1), Array(33, 1), Array(49 _
, 1), Array(65, 1), Array(80, 1), Array(93, 1)), TrailingMinusNumbers:=True
'Set-up Top Layout
Columns("A:F").Select
Columns("A:F").EntireColumn.AutoFit
ActiveWindow.SmallScroll Down:=3
Rows("1:25").Select
Range("A25").Activate
Selection.Delete Shift:=xlUp
Range("A3").Select
ActiveCell.FormulaR1C1 = "=RC[1]&RC[2]"
Range("A4").Select
ActiveCell.FormulaR1C1 = "=RC[1]&RC[2]"
Range("A4").Select
Selection.ClearContents
Range("D4").Select
ActiveCell.FormulaR1C1 = "=TEXT(RC[-1],m/dd/yy)"
Range("D4").Select
ActiveCell.FormulaR1C1 = "=TEXT(RC[-1],""m/dd/yy"")"
Range("A4").Select
ActiveCell.FormulaR1C1 = "=RC[1]&RC[3]"
Range("A7").Select
ActiveCell.FormulaR1C1 = _
"=CONCATENATE(R[-1]C,"": "",R[-1]C[1],"" "",R[-1]C[2])"
Range("A7").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("A7").Cut Destination:=Range("A6")
Range("A7").Select
ActiveCell.FormulaR1C1 = "=R[-1]C[4]&R[-1]C[5]"
Range("A1:A7").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("B1:E7").Select
Application.CutCopyMode = False
Selection.ClearContents
Range("F6").Select
Selection.ClearContents
Range("D1").Select
ActiveCell.FormulaR1C1 = "Based on Report Run:"
Range("D1").Select
Selection.Cut Destination:=Range("E1")
Range("E1").Select
With Selection
.HorizontalAlignment = xlRight
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("E2").Select
ActiveCell.FormulaR1C1 = "at:"
Range("E2").Select
With Selection
.HorizontalAlignment = xlRight
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("E1:F2").Select
Selection.Cut Destination:=Range("H1:I2")
Columns("E:F").Select
Selection.Delete Shift:=xlToLeft
Range("E9").Select
ActiveCell.FormulaR1C1 = "Increase"
Range("F9").Select
ActiveCell.FormulaR1C1 = "Decrease"
Range("G8").Select
ActiveCell.FormulaR1C1 = "Revised"
Range("G9").Select
ActiveCell.FormulaR1C1 = "YTD"
Range("D10").Select
Selection.AutoFill Destination:=Range("D10:G10"), Type:=xlFillDefault
Range("D10:G10").Select
Range("H14").Select
Columns("B:B").EntireColumn.AutoFit
Columns("B:G").Select
Columns("B:G").EntireColumn.AutoFit
Range("H8").Select
Columns("B:B").ColumnWidth = 12
Columns("B:G").Select
Selection.ColumnWidth = 12
Range("H9").Select
ActiveCell.FormulaR1C1 = "Explanation"
Range("G10").Select
Selection.AutoFill Destination:=Range("G10:H10"), Type:=xlFillDefault
Range("G10:H10").Select
Columns("H:H").ColumnWidth = 17.57
Range("H13").Select
Columns("H:H").ColumnWidth = 26.71
Range("F1:G2").Select
Selection.Cut Destination:=Range("G1:H2")
Range("H4").Select
ActiveWindow.SmallScroll Down:=-12
'Scaffolding
Columns("A:B").Select
Selection.Insert Shift:=xlToRight
Range("c3000").Select
Range(Selection, Selection.End(xlUp)).Select
ActiveCell.Offset(0, -1).Select
ActiveCell.FormulaR1C1 = "x"
ActiveCell.Offset(0, -1).Select
ActiveCell.FormulaR1C1 = "x"
Range("A1").Select
ActiveCell.FormulaR1C1 = "1"
Range("A2").Select
ActiveCell.FormulaR1C1 = "2"
Dim RwLast As Long
RwLast = Range("A65536").End(xlUp).Row
Range("A1:A2").Select
Selection.AutoFill Destination:=Range("A1:A" & RwLast), Type:=xlFillDefault
Range("A1").Select
ActiveCell.EntireRow.Insert
Range("A1").Select
ActiveCell.FormulaR1C1 = "Line"
Range("B1").Select
ActiveCell.FormulaR1C1 = "Keep"
Range("C1").Select
ActiveCell.FormulaR1C1 = "Desc"
Range("D1").Select
ActiveCell.FormulaR1C1 = "Prior YTD"
Range("E1").Select
ActiveCell.FormulaR1C1 = "Current Yr"
Range("F1").Select
ActiveCell.FormulaR1C1 = "Current YTD"
Range("G1").Select
ActiveCell.FormulaR1C1 = "Increase"
Range("H1").Select
ActiveCell.FormulaR1C1 = "Decrease"
Range("I1").Select
ActiveCell.FormulaR1C1 = "YTD"
Range("J1").Select
ActiveCell.FormulaR1C1 = "Explanation"
Columns("C:D").Select
Selection.Insert Shift:=xlToRight
Range("D12").Select
ActiveCell.FormulaR1C1 = "=LEFT(RC[1],3)"
Range("C12").Select
ActiveCell.FormulaR1C1 = "1"
Range("e2000").Select
Range(Selection, Selection.End(xlUp)).Select
ActiveCell.Offset(0, -1).Select
ActiveCell.FormulaR1C1 = "x"
ActiveCell.Offset(0, -1).Select
ActiveCell.FormulaR1C1 = "x"
ActiveCell.Offset(0, -1).Select
ActiveCell.FormulaR1C1 = "x"
Range("c12:d12").Select
Selection.Copy
Range("C13:D13").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveSheet.Paste
Range("h2000").Select
Range(Selection, Selection.End(xlUp)).Select
ActiveCell.Offset(0, 1).Select
ActiveCell.FormulaR1C1 = "x"
ActiveCell.Offset(0, 1).Select
ActiveCell.FormulaR1C1 = "x"
ActiveCell.Offset(0, 1).Select
ActiveCell.FormulaR1C1 = "x"
ActiveCell.Offset(0, 3).Select
ActiveCell.FormulaR1C1 = "x"
ActiveCell.Offset(0, 1).Select
ActiveCell.FormulaR1C1 = "x"
ActiveCell.Offset(0, 1).Select
ActiveCell.FormulaR1C1 = "x"
ActiveCell.Offset(0, 1).Select
ActiveCell.FormulaR1C1 = "x"
ActiveCell.Offset(0, 1).Select
ActiveCell.FormulaR1C1 = "x"
ActiveCell.Offset(0, 1).Select
ActiveCell.FormulaR1C1 = "x"
'Eliminate Superfluous Info
Columns("D:D").Select
Selection.Copy
Columns("C:C").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlMultiply, _
SkipBlanks:=False, Transpose:=False
Range("b12").Select
ActiveCell.Formula = "=IF(OR(C12=401,AND(E10=""Sub-total"",D12=""475""),and(d12=""233"",f11=""----------------"")),""Delete"",IF(OR(AND(G12=""----------------"",E13=""Sub-total""),E11=""Margin Percent (Directs)"",E11=""Sub-total"",e11=""Total Directs"",E12=""Direct Labor"",E12=""Cost Per Directory"",E12=""Cost Per Stop"",E12=""Sub-total"",E12=""Distribution"",E12=""DIRECT OPER. COST"",E12=""Allocated Costs"",E12=""PR Load"",E12=""Total Directs"",E12=""Revenue"",E12=""Gross Margin"",E12=""Margin Percent (Sales)"",E12=""Margin Percent (Directs)"",E12=""Directories"",E12=""Stops"",E12=""Ops Statistics"",AND(ISNUMBER(C12),C12>1)),"""",""Delete""))"
ActiveCell.Copy
Range("b13").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveSheet.Paste
Range("B:B").Copy
Range("B:B").PasteSpecial xlPasteValues
Range("A1:L1").Select
Application.CutCopyMode = False
Selection.AutoFilter
Selection.AutoFilter Field:=2, Criteria1:="Delete"
Rows("13:13").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Delete Shift:=xlUp
Selection.AutoFilter Field:=2
Range("e2000").Select
Range(Selection, Selection.End(xlUp)).Select
ActiveCell.Offset(0, -3).Select
ActiveCell.FormulaR1C1 = "x"
Range("b12").Select
ActiveCell.Formula = "=IF(E11=""Cost Per Stop"",""Delete"",IF(B11=""Delete"",""Delete"",""""))"
ActiveCell.Copy
Range("b13").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveSheet.Paste
Range("B:B").Copy
Range("B:B").PasteSpecial xlPasteValues
Selection.AutoFilter Field:=2, Criteria1:="Delete"
Rows("13:13").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Delete Shift:=xlUp
Selection.AutoFilter Field:=2
'Set Print Area
Dim RwLast4 As Long
RwLast4 = Range("h65536").End(xlUp).Row
'LastRowInJ = ActiveSheet.Cells(Rows.Count, "J").End(xlUp).Row
'ActiveSheet.PageSetup.PrintArea = "$A$5:$I$" & LastRowInJ
ActiveSheet.PageSetup.PrintArea = "$E$1:$L$" & RwLast4
With ActiveSheet.PageSetup
.PrintTitleRows = "$9:$11"
.PrintTitleColumns = ""
End With
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.5)
.RightMargin = Application.InchesToPoints(0.5)
.TopMargin = Application.InchesToPoints(0.5)
.BottomMargin = Application.InchesToPoints(0.5)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = True
.CenterVertically = False
.Orientation = xlPortrait
.Draft = False
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100
.PrintErrors = xlPrintErrorsDisplayed
End With
With ActiveSheet.PageSetup
.PrintTitleRows = "$9:$11"
.PrintTitleColumns = ""
End With
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = "Page &P of &N"
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.5)
.RightMargin = Application.InchesToPoints(0.5)
.TopMargin = Application.InchesToPoints(0.5)
.BottomMargin = Application.InchesToPoints(0.5)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = True
.CenterVertically = False
.Orientation = xlPortrait
.Draft = False
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 72
.PrintErrors = xlPrintErrorsDisplayed
End With
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = "Page &P of &N"
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.5)
.RightMargin = Application.InchesToPoints(0.5)
.TopMargin = Application.InchesToPoints(0.5)
.BottomMargin = Application.InchesToPoints(0.75)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = True
.CenterVertically = False
.Orientation = xlPortrait
.Draft = False
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 72
.PrintErrors = xlPrintErrorsDisplayed
End With
ActiveWindow.View = xlNormalView
ActiveWindow.SmallScroll Down:=-21
Dim wstSheet As Worksheet
Set wstSheet = ActiveSheet
With wstSheet
With .PageSetup
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = False
End With
End With
Range("F2").Select
'Determine Nature of Rows (Box or Total)
Range("I13").Select
ActiveCell.Formula = "=IF(AND($E13=""Gross Margin"", ISBLANK(F13)),"""",IF(OR($E13=""Sub-total"",$E13=""Total Directs"",$E13=""Cost Per Directory"",$E13=""Cost Per Stop"",$E13=""Gross Margin"",LEFT($E13,6)=""Margin""),""Total"",IF($F13=""----------------"",""----------------"",if($F13=""****************"",""****************"",IF($C13>1,""Box"","""")))))"
ActiveCell.Copy
Range("J13").Select
ActiveSheet.Paste
Range("I13:J13").Copy
Range("I14:J14").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveSheet.Paste
'R[-1]C[4]
End Sub