Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
sort method frustration
The is method the first sort works fine.
srange.Sort _ Key1:=Cells(1, intSortColumn), Order1:=xlAscending, Header:=xlYes When I want to sort directly after by second column. I receive runtime error "1004" srange.Sort _ Key1:=Cells(1, intSortColumn2), Order1:=xlAscending, Header:=xlYes intsortcolumn2 does hold a value srange is a valid object. row 1 is the header. Ideally I would like sort by both keys at the same time. I used the macro record Selection.Sort Key1:=Range(Cells(1, intSortColumn), Cells(1, intSortColumn)), Order1:=xlAscending, _ Key2:=Range(Cells(1, intSortColumn2), Cells(1, intSortColumn2)) _ , Order2:=xlAscending, Header:=xlYes, OrderCustom:=1, MatchCase:= _ False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _ :=xlSortNormal Same error results. Why is sort such a pain in the you know where? Any ideas? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
sort method frustration
David,
I can't think of much else that might be causing the problem. Is worksheet containing sRange active when you execute the sort? -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "David Wenahm" wrote in message ... Chip, Thanks for your Help! Yes I have checked the srange address, I am sorting 6 six columns of data and intsortcolumn2 = 6 prior and during the statement. There is header data which is what the key is pointing to. Range address is $A$1:$F$154 srange is also set prior to the sort. further suggestions? David -----Original Message----- David, Does the srange range contain the key cell? -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "David Wenham" wrote in message ... The is method the first sort works fine. srange.Sort _ Key1:=Cells(1, intSortColumn), Order1:=xlAscending, Header:=xlYes When I want to sort directly after by second column. I receive runtime error "1004" srange.Sort _ Key1:=Cells(1, intSortColumn2), Order1:=xlAscending, Header:=xlYes intsortcolumn2 does hold a value srange is a valid object. row 1 is the header. Ideally I would like sort by both keys at the same time. I used the macro record Selection.Sort Key1:=Range(Cells(1, intSortColumn), Cells(1, intSortColumn)), Order1:=xlAscending, _ Key2:=Range(Cells(1, intSortColumn2), Cells(1, intSortColumn2)) _ , Order2:=xlAscending, Header:=xlYes, OrderCustom:=1, MatchCase:= _ False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _ :=xlSortNormal Same error results. Why is sort such a pain in the you know where? Any ideas? . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Need really fast method to sort data for my part numbering spread | Excel Discussion (Misc queries) | |||
Please post this thread a correct full method, method about | New Users to Excel | |||
Please post this thread a complete correct method, method about te | New Users to Excel | |||
VBA Sort method w/more than 3 Keys | Excel Discussion (Misc queries) | |||
Sort method of range | Excel Programming |