View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Error trying to sort in a Macro Error trying to sort in a Macro is offline
external usenet poster
 
Posts: 5
Default Writing a Sort Macro

Thanks so far....



I added the range to the front of the sort:

Sheets("OPEN").Select
Range("A:BZ").Sort Key1:=Range("Y2"), Order1:=xlAscending,
Key2:=Range("AE2") _
, Order2:=xlAscending, Key3:=Range("AB2"), Order3:=xlAscending,
Header _
:=xlGuess, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom _
, DataOption1:=xlSortNormal, DataOption2:=xlSortNormal,
DataOption3:= _
xlSortNormal


Now, it doesn't error out. It doesn't sort either. Do I need to specify on
which sheet the range is? I tried using the Sheet("Open").Range(....
command, but that errors out with the same application error.

Thanks for your help.

---Ken
"Jim Cone" wrote:


EttsiaM,
You also have to select the sort range on the Open sheet.
--
Jim Cone
Portland, Oregon USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"Error trying to sort in a Macro"
wrote in message
I have the following code that I'm trying to use to sort:

Sheets("OPEN").Select
Selection.Sort Key1:=Range("Y2"), Order1:=xlAscending, Key2:=Range("AE2") _
, Order2:=xlAscending, Key3:=Range("AB2"), Order3:=xlAscending, Header _
:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom _
, DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, DataOption3:= _
xlSortNormal

It errors out with the error:
'Runtime error "1004"
Application-defined or Object-defined error'