Having trouble getting sort to work in a macro
Perhaps you want to change x1Ascending and x1Descending to xlAscending and
xlDescending. (the letter "l"; not the number "1").
Using Option Explicit would help to avoid these problems in the first place!
:-)
--
Vasant
"Mark" wrote in message
...
I'm trying to get a sort statement to work within a macro and having very
little success.
here'a a code snippet:
Worksheets("TempLstData").Select
Range("A1:AX256").Sort Key1:=Range("p2"), Order1:=x1Ascending,
Key2:=Range("al2") _
, Order2:=x1Descending, Header:=xlGuess, OrderCustom:=1,
MatchCase:=True _
, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal,
DataOption2:=xlSortNormal
I got this code from funning the macro recorder... I have a small test
worksheet on which this bit of code seems to work, but when I try to run
it
within the actual workbook I get the following (very helpful?) error
message:
Run-time error '1004'
Sort method of Range class failed.
When I click on the debug link I see the entire sort statement highlited.
The help link takes me to a very non-specific error message about a Macro
error.
ANy help or insights will be greatly appreciated. I'm trying to get this
sort capability added to a worksheet that is due in the morning.
Mark
|