Sub Macro15()
'
' Macro15 Macro
' Range("A10:C10").Select
Selection.ClearContents
Sheets("Factory Billing Data").Select
Columns("A:A").Select
Selection.TextToColumns Destination:=Range("A1"), DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 2), Array(21, 1), Array(51, 1), Array(60, 1), Array(75, 1), _
Array(94, 1), Array(116, 1)), TrailingMinusNumbers:=True
Columns("A:G").Select
Columns("A:G").EntireColumn.AutoFit
Dim Counter
Dim i As Long
Counter = InputBox("Enter Amount of Rows to Delete")
ActiveCell.Select
For i = 1 To Counter
If ActiveCell = "" Then
Selection.EntireRow.Delete
Counter = Counter - 1
Else
ActiveCell.Offset(1, 0).Select
End If
Next i
Columns("A:B").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
ActiveCell.FormulaR1C1 = "=IF(LEFT(RC[2],3)=""000"",R[1]C[2],"""")"
Range("B1").Select
ActiveCell.FormulaR1C1 = "=IF(LEFT(RC[1],3)=""000"",R[1]C[2],"""")"
Range("A1:B1").Select
Selection.AutoFill Destination:=Range("A1:B50000")
Range("A1:B50000").Select
' Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("A1:I50001").Select
Range("A1").Activate
Application.CutCopyMode = False
ActiveWorkbook.Worksheets("Factory Billing Data").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Factory Billing Data").Sort.SortFields.Add Key:= _
Range("A1:A50001"), SortOn:=xlSortOnValues, Order:=xlDescending, _
DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Factory Billing Data").Sort
.SetRange Range("A1:I50001")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
ActiveWindow.SmallScroll Down:=-5
Rows("1:1").Select
Application.CutCopyMode = False
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
With ActiveSheet
.AutoFilterMode = False
With Range("a1", Range("a" & Rows.Count).End(xlUp))
.AutoFilter 1, ""
On Error Resume Next
.Offset(1).SpecialCells(12).EntireRow.Delete
End With
.AutoFilterMode = False
Columns("E:E").Select
Selection.Delete Shift:=xlToLeft
Sheets("Factory Billing Macro").Select
Range("A1:G1").Select
Selection.Copy
Sheets("Factory Billing Data").Select
Range("A1").Select
ActiveSheet.Paste
Columns("A:G").Select
Columns("A:G").EntireColumn.AutoFit
Columns("A:A").Select
Application.CutCopyMode = False
With Selection
.HorizontalAlignment = xlRight
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Columns("B:B").Select
With Selection
.HorizontalAlignment = xlRight
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Columns("E:E").Select
Selection.Style = "Currency"
Columns("F:F").Select
Selection.Style = "Currency"
Columns("G:G").Select
Selection.Style = "Currency"
ActiveWorkbook.RefreshAll
Sheets("Factory Billing Macro").Select
Range("A10").Select
ActiveCell.FormulaR1C1 = "=SUM('Factory Billing Data'!R[-8]C[4]:R[49990]C[4])"
Range("A10").Select
Selection.AutoFill Destination:=Range("A10:C10"), Type:=xlFillDefault
Range("A10:C10").Select
End With
'
'
End Sub
Bookmarks