I have written a basic code to paste and sort data. It works fine when i write it, though if I close Excel it never works again. Can anyone see why.
Code is designed to paste data copied from a report sorted to be used for a mail merge.
Sub Update_Paypal()
Application.ScreenUpdating = False
'clear Data from Sheets
Sheets("PayPal Input").Select
Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.ClearContents
Sheets("SortedData").Select
Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.ClearContents
'paste data to be sorted
Sheets("PayPal Input").Select
Range("A1").Select
ActiveSheet.Paste
'sort data
Columns("P:P").Select
Range("A1:AP10").Sort Key1:=Range("P1"), Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Sheets("SortedData").Select
Range("A1").Select
ActiveSheet.Paste
Sheets("Admin").Select
Application.ScreenUpdating = True
ActiveWorkbook.Save
End Sub
Bookmarks