I have Excel 2007 and Windows XP When this code runs:
Columns("A:G").Select
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range("B2:B20000") _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range("A2:A20000") _
, SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range("F2:F20000") _
, SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").Sort
.SetRange Range("A1:G20000")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Application.Calculation = xlCalculationAutomatic
It throws an error at .Apply
:
Application-defined or object-defined error
One thing to note is that Application.Calculation = xlCalculationManual
Also, I cannot do anything in the UI except for switching tabs and opening the office menu, and I have to go to the Task Manager and click end task to exit, whereupon it asks if I want to save. Pressing cancel does not fix it. If I hit "no", it just closes. If I hit yes, it calculates and then asks if I want to have it recover my work.