Sub SlsInvSheet()
'
' Builds Inv Sheet for Salesman
'
'
FinalRow = Cells(Rows.Count, 2).End(xlUp).Row
Range("G1").ColumnWidth = 10
Columns("H:R").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
' SET COLUMN TITLES
Range("C1:R1").Value = Array("VIN", "MAKE", "MODEL", "YR", _
"WB", "ENGINE", "HP", "TRANS", "FA", "RA", _
"RATIO", "GVW", "SUSP", "BRAKES", "WHEELS", "TIRES", "MILES", _
"COLOR", "SOURCE")
' INSERT COLUMN FOR DAYS TO TRACK AGEING
Columns("W:W").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("W1").Select
ActiveCell.FormulaR1C1 = "DAYS"
Range("W2").Select
ActiveCell.FormulaR1C1 = "=TODAY()-RC[-1]"
Range("W2").NumberFormat = "0"
Range("W2").Copy Destination:=Range("W3:W" & FinalRow)
ActiveCell.Range("A1:A" & FinalRow).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues
' Turn off Alerts
Application.DisplayAlerts = False
' SPLIT OPTIONS TO INDIVIDUAL COLUMNS
Range("G2:G" & FinalRow).TextToColumns Destination:=ActiveCell.Offset(0, -16), _
DataType:=xlDelimited, Tab:=False, Other:=True, OtherChar:="*", FieldInfo:=Array(1, 1)
' Turn On Alerts
Application.DisplayAlerts = True
' If New Vehicle SetProfile by Account Number, If Used Do Nothing
For i = 2 To FinalRow
Select Case Cells(i, 30).Value
Case 13200
ActiveCell.Offset(i - 2, -22).Formula = ActiveCell.Offset(i - 2, -18)
Case 13300
ActiveCell.Offset(i - 2, -22).Formula = "Nav-Othr"
Case 13350
ActiveCell.Offset(i - 2, -22).Formula = "UD"
Case Else
End Select
Next i
' Delete Entry Column
ActiveCell.Offset(0, -1).Columns("A:A").EntireColumn.Delete Shift:=xlToLeft
Cells(1, 23).Formula = "SOURCE"
Cells(1, 27).Formula = "CNTL"
Cells(1, 26).Formula = "PGM"
' Sort by New/Used by Profile By Stk #
Cells(2, 29).Select
ActiveSheet.Sort.SortFields.Clear
ActiveSheet.Sort.SortFields.Add Key _
:=ActiveCell.Range("A1:A" & FinalRow - 1), SortOn:=xlSortOnValues, Order:=xlAscending _
, DataOption:=xlSortNormal
ActiveSheet.Sort.SortFields.Add Key _
:=ActiveCell.Offset(0, -28).Range("A1:A" & FinalRow), SortOn:=xlSortOnValues, Order:= _
xlAscending, DataOption:=xlSortNormal
ActiveSheet.Sort.SortFields.Add Key _
:=ActiveCell.Offset(0, -27).Range("A1:A" & FinalRow), SortOn:=xlSortOnValues, Order:= _
xlAscending, DataOption:=xlSortNormal
With ActiveSheet.Sort
.SetRange ActiveCell.Offset(0, -28).Range("A1:AC" & FinalRow)
.Apply
End With
' After first if Profile is the same delete it, When it changes insert row
Cells(2, 1).Select
Selection.Font.Bold = True
For i = FinalRow To 1 Step -1
If ActiveCell.Offset(i, 0) = ActiveCell.Offset(i - 1, 0) Then
ActiveCell.Offset(i, 0).Clear
Else
ActiveCell.Offset(i, 0).Font.Bold = True
ActiveCell.Offset(i, 0).Rows("1:1").EntireRow _
.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
End If
Next i
' Move Profile Above Stock Number and Bold Face
Cells(2, 1).Select
For i = 2 To FinalRow
If Cells(i, 1) <> "" Then
Cells(i, 1).Rows("1:1").EntireRow _
.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Cells(i + 1, 1).Cut Destination:=Cells(i, 2)
With Cells(i, 2).Font
.FontStyle = "Bold"
.Size = 14
End With
End If
Next i
' AutoFit Columns
ActiveCell.Offset(0, 1).Columns("A:AA").EntireColumn.Select
ActiveCell.Columns("A:AA").EntireColumn.EntireColumn.AutoFit
' Center Columns
Range("B1:AB" & FinalRow).HorizontalAlignment = xlCenter
' Add Gridlines
With Selection.Borders
.LineStyle = xlContinuous
.Weight = xlThin
End With
' Round CONTROL
Cells(1, 27).Range("A1:A" & FinalRow).NumberFormat = "0"
' Left Justify Profile Names
Cells(2, 2).Select
EndRow = False
Do While CountRow < FinalRow
For i = 2 To FinalRow
CountRow = CountRow + 1
If Cells(i, 2).Font.Size = 14 Then
Cells(i, 2).HorizontalAlignment = xlLeft
End If
Next i
Loop
TopRow = ActiveCell.Address
BottomRow = ActiveCell.SpecialCells(xlCellTypeLastCell).Address
LastRow = Range(BottomRow).Cells(1, -1).Address
Application.PrintCommunication = False
With ActiveSheet.PageSetup
.PrintTitleRows = "$1:$1"
.PrintTitleColumns = ""
End With
Application.PrintCommunication = True
With ActiveSheet
.PageSetup.PrintArea = .Range(TopRow, LastRow).Address
End With
Application.PrintCommunication = False
With ActiveSheet.PageSetup
.LeftHeader = "&""Arial,Bold Italic""&16Wallace International Trucks Inc"
.CenterHeader = "&""Arial,Bold""&14New / Used Inventory Details"
.RightHeader = "&A"
.LeftFooter = ""
.CenterFooter = "Page &P of &N"
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.5)
.RightMargin = Application.InchesToPoints(0.5)
.TopMargin = Application.InchesToPoints(1)
.BottomMargin = Application.InchesToPoints(1)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperLegal
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = False
.PrintErrors = xlPrintErrorsDisplayed
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.ScaleWithDocHeaderFooter = True
.AlignMarginsHeaderFooter = True
.EvenPage.LeftHeader.Text = ""
.EvenPage.CenterHeader.Text = ""
.EvenPage.RightHeader.Text = ""
.EvenPage.LeftFooter.Text = ""
.EvenPage.CenterFooter.Text = ""
.EvenPage.RightFooter.Text = ""
.FirstPage.LeftHeader.Text = ""
.FirstPage.CenterHeader.Text = ""
.FirstPage.RightHeader.Text = ""
.FirstPage.LeftFooter.Text = ""
.FirstPage.CenterFooter.Text = ""
.FirstPage.RightFooter.Text = ""
End With
Application.PrintCommunication = True
' Set Page Break at Beginning of Used
Range("A1").Select
LastColumn = Cells(1, Columns.Count).End(xlToLeft).Column
IsUsed = False
Do While IsUsed = False
For i = 2 To FinalRow
If Cells(i, LastColumn) > 13500 Then
ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=ActiveCell _
.Offset(i - 1, LastColumn)
i = FinalRow
End If
Next i
IsUsed = True
Loop
End Sub