ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Selection.Sort error (https://www.excelbanter.com/excel-programming/339136-selection-sort-error.html)

Krager

Selection.Sort error
 

ActiveSheet.Range("C7").Select
ActiveSheet.Range(Selection, Selection.End(xlDown)).Select


Selection.Sort Key1:=Range("C7"), Order1:=xlAscending, Header:=xlGuess,
_ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom


In the above code, the select statements are working correctly, so the
range I want is selected, however I get an error on the Selection.Sort
statement every time. Any thoughts?


--
Krager
------------------------------------------------------------------------
Krager's Profile: http://www.excelforum.com/member.php...o&userid=20936
View this thread: http://www.excelforum.com/showthread...hreadid=401705


Krager[_2_]

Selection.Sort error
 

Ok fixed my own problem, just added an ActiveSheet. in front of the
Range in the selection statement and that solved it.

Selection.Sort Key1:=ActiveSheet.Range("C7"), Order1:=xlAscending,
Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom


--
Krager
------------------------------------------------------------------------
Krager's Profile: http://www.excelforum.com/member.php...o&userid=20936
View this thread: http://www.excelforum.com/showthread...hreadid=401705


Don Guillett[_4_]

Selection.Sort error
 
I tested yours and it worked but you may want to try this instead

Sub sortmyrange()
Range("C7", Range("C7").End(xlDown)). _
Sort Key1:=Range("C7"), Order1:=xlAscending
End Sub

--
Don Guillett
SalesAid Software

"Krager" wrote in
message ...

ActiveSheet.Range("C7").Select
ActiveSheet.Range(Selection, Selection.End(xlDown)).Select


Selection.Sort Key1:=Range("C7"), Order1:=xlAscending, Header:=xlGuess,
_ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom


In the above code, the select statements are working correctly, so the
range I want is selected, however I get an error on the Selection.Sort
statement every time. Any thoughts?


--
Krager
------------------------------------------------------------------------
Krager's Profile:

http://www.excelforum.com/member.php...o&userid=20936
View this thread: http://www.excelforum.com/showthread...hreadid=401705




Tim Williams

Selection.Sort error
 
What's the text of the error?

Tim

"Krager" wrote
in message ...

ActiveSheet.Range("C7").Select
ActiveSheet.Range(Selection, Selection.End(xlDown)).Select


Selection.Sort Key1:=Range("C7"), Order1:=xlAscending,
Header:=xlGuess,
_ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom


In the above code, the select statements are working correctly, so
the
range I want is selected, however I get an error on the
Selection.Sort
statement every time. Any thoughts?


--
Krager
------------------------------------------------------------------------
Krager's Profile:
http://www.excelforum.com/member.php...o&userid=20936
View this thread:
http://www.excelforum.com/showthread...hreadid=401705





All times are GMT +1. The time now is 10:52 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com