Sub DataSort()
'
' DataSort Macro
' Sorts and sums data from Scrap Download.
'
' Keyboard Shortcut: Ctrl+Shift+T
'
Dim i As Long
Rows("1:1").EntireRow.Delete
Columns("A:A").EntireColumn.Delete
Columns("F:F").Insert Shift:=xlToRight
Columns("E:E").Copy Range("F1")
Range("F:F").Replace What:="2nd-", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByColumns, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Range("F:F").Replace What:="1st-", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByColumns, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Range("A1:J27").Sort Key1:=Range("F1"), Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortTextAsNumbers
Columns("H:H").EntireColumn.Cut Columns("K:K")
Columns("H:H").EntireColumn.Delete
Columns("J:J").HorizontalAlignment = xlCenter
Range("K5") = "51"
Range("K6") = "53"
Range("K7") = "54"
Range("K8") = "58"
Range("K9") = "59"
Range("L5").FormulaR1C1 = _
"=SUMIF(R[-4]C[-6]:R[95]C[-6],RC[-1],R[-4]C[-8]:R[95]C[-8])"
Range("L6").FormulaR1C1 = _
"=SUMIF(R[-5]C[-6]:R[94]C[-6],RC[-1],R[-5]C[-8]:R[94]C[-8])"
Range("L7").FormulaR1C1 = _
"=SUMIF(R[-6]C[-6]:R[93]C[-6],RC[-1],R[-6]C[-8]:R[93]C[-8])"
Range("L8").FormulaR1C1 = _
"=SUMIF(R[-7]C[-6]:R[92]C[-6],RC[-1],R[-7]C[-8]:R[92]C[-8])"
Range("L9").FormulaR1C1 = _
"=SUMIF(R[-8]C[-6]:R[92]C[-6],RC[-1],R[-8]C[-8]:R[91]C[-8])"
i = 1
Do Until Cells(i, "A") = ""
'Cells(i, "A") = Left(Cells(i, "A"), 6) & "20" & Right(Cells(i, "A"), 2)
Cells(i, "A") = DateSerial(2000 + CLng(Right(Cells(i, "A"), 2)), _
CLng(Left(Cells(i, "A"), 2)), _
CLng(Mid(Cells(i, "A"), 4, 2)))
i = i + 1
Loop
Range("A:A").NumberFormat = "mm/dd/yy"
' Format as text
Range("B:B", "H:H").NumberFormat = "@"
End Sub
Bookmarks