My boss (not a spreadsheet man ) has created the following code to move some data around his spreadsheet, to be honest I'm quite impressed he has got this far!
I am going to improve it when I get chance, but an immediate issue is when the code runs, the last cell of excel becomes T1048574, and then the rest of the code fails as it is trying to shift data off the sheet.
Is there a very quick fix that I can apply in the meantime to do away with this issue?
Thanks
I am going to improve it when I get chance, but an immediate issue is when the code runs, the last cell of excel becomes T1048574, and then the rest of the code fails as it is trying to shift data off the sheet.
Is there a very quick fix that I can apply in the meantime to do away with this issue?
Thanks
Code:
Sub Macro1()
'
' Macro1 Macro
'
' Keyboard Shortcut: Ctrl+f
'
Range("A:A,C:C,E:E").Select
Range("E1").Activate
Application.CutCopyMode = False
Selection.Delete Shift:=xlToLeft
Cells.Select
Cells.EntireColumn.AutoFit
Columns("C:C").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("B1").Select
Selection.Copy
Range("C1").Select
ActiveSheet.Paste
Columns("B:B").Select
Application.CutCopyMode = False
Selection.TextToColumns Destination:=Range("B1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
:="-", FieldInfo:=Array(Array(1, 1), Array(2, 1)), TrailingMinusNumbers:=True
Range("C1").Select
ActiveCell.FormulaR1C1 = "Amount"
Rows("1:1").Select
Selection.AutoFilter
ActiveSheet.Range("$A$1:$G$35").AutoFilter Field:=2, Criteria1:="<>"
Columns("A:D").Select
Selection.Copy
Range("H1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Rows("1:1").Select
Application.CutCopyMode = False
Selection.AutoFilter
Selection.AutoFilter
ActiveSheet.Range("$A$1:$K$35").AutoFilter Field:=3, Criteria1:="<>"
Columns("A:D").Select
Selection.Copy
Range("Q1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Rows("1:1").Select
Application.CutCopyMode = False
Selection.AutoFilter
Columns("A:G").Select
Selection.Delete Shift:=xlToLeft
Range("A:A,J:J").Select
Range("J1").Activate
Selection.NumberFormat = "m/d/yyyy"
Range("C:C,K:K").Select
Range("K1").Activate
Selection.Delete Shift:=xlToLeft
Range("C:C,K:K").EntireColumn.AutoFit
Columns("A:A").Select
ActiveWorkbook.Worksheets("Paste Page").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Paste Page").Sort.SortFields.Add Key:=Range( _
"A2:A1048564"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Paste Page").Sort
.SetRange Range("A1:C1048564")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Columns("I:I").Select
ActiveWorkbook.Worksheets("Paste Page").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Paste Page").Sort.SortFields.Add Key:=Range( _
"I2:I1048564"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Paste Page").Sort
.SetRange Range("I1:K1048564")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Columns("E:H").Select
Selection.Delete Shift:=xlToLeft
Columns("D:D").Select
Selection.Style = "Good"
Rows("1:3").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Range("A2").Select
ActiveCell.FormulaR1C1 = "Received"
Range("E2").Select
ActiveCell.FormulaR1C1 = "Payments Out"
Rows("2:2").Select
Selection.Font.Size = 11
Selection.Font.Size = 12
Selection.Font.Size = 14
Selection.Font.Size = 16
Selection.Font.Size = 18
Selection.Font.Size = 20
With Selection.Font
.Name = "Arial"
.Size = 20
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
Range("C9").Select
Columns("A:A").Select
Selection.Cut
Columns("K:K").Select
Selection.Insert Shift:=xlToRight
Columns("B:B").Select
Selection.Cut
Columns("K:K").Select
Selection.Insert Shift:=xlToRight
Columns("A:B").Select
Selection.Cut
Columns("M:M").Select
Selection.Insert Shift:=xlToRight
Columns("A:A").Select
Selection.Cut
Columns("M:M").Select
Selection.Insert Shift:=xlToRight
Columns("B:B").Select
Selection.Cut
Columns("M:M").Select
Selection.Insert Shift:=xlToRight
Columns("A:D").Select
Selection.Cut
Columns("O:O").Select
Selection.Insert Shift:=xlToRight
End Sub