Hi all,
Here is the code with 6 alternatives to execute a simple ".Sort.SortFields.Clear" command.
None of them work on my PC but they all do on other computers. All alternatives on my PC show the
"run-time error '9': subscript out of range". Please note that I get the same error with the "AutoFilter" command.
This thread has also been posted on the Microsoft community website.
Thanks very much, Alan.
Sub test_autosort()
ActiveWorkbook.Worksheets("Sheet1").AutoFilterMode = False
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
' 1st alternative
' Rows("6:800").Select
' Worksheets("Sheet1").Sort.SortFields.Clear
' 2nd alternative
' With ActiveSheet
' .Sort.SortFields.Clear
' End With
' 3rd alternative
' With Worksheets("Sheet1")
' .Sort.SortFields.Clear
' End With
' 4th alternative
' With Worksheets(1)
' .Sort.SortFields.Clear
' End With
'
'5th alternative
'ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear
'6th alternative
With ActiveWorkbook
Worksheets(1).Sort.SortFields.Clear
End With
End Sub
.Sort.Sortfields.Clear.PNG
Bookmarks