Serving the Quantitative Finance Community

 
User avatar
LawfulEvil
Topic Author
Posts: 0
Joined: May 21st, 2003, 9:13 am

Vba sorting question

March 13th, 2006, 2:21 am

Dear all,How can load a table of data into a range and apply excel's sorting function?I know I can write a bubble sort to do it but I don't want to use bubble sort in this case.I don't want to open a new worksheet, load all data, sort, and read all data, time consuming... e.g.dim temp_data(3,2) as stringtemp_data(1,1) = "z"temp_data(2,1) = "x"temp_data(3,1) = "y"temp_data(1,2) = "3"temp_data(2,2) = "1"temp_data(3,2) = "2"'===== the following code not working=========== dim myRange as rangemyRange = temp_datamyRange.sort Key1:=myRange(1,1), Header:=xlNotemp_data = myRange'======================================Please give me some hints, thank you.
 
User avatar
mensa0
Posts: 0
Joined: January 20th, 2004, 8:56 am

Vba sorting question

March 14th, 2006, 9:17 am

Why wouldn't something like this work? Range("A4:B15").Select Selection.Sort Key1:=Range("A4"), Order1:=xlAscending, Key2:=Range("B4") _ , Order2:=xlAscending, Header:=xlNo, OrderCustom:=1, MatchCase:= _ True, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _ :=xlSortNormal
 
User avatar
LawfulEvil
Topic Author
Posts: 0
Joined: May 21st, 2003, 9:13 am

Vba sorting question

March 17th, 2006, 7:07 am

i got a table of data in temp_datathe size is 45000 + rows, 12 columnsi want to do a sorting in this temp_data(45000,12) via vbait will be a very time consuming task to use a bubble sortI know I can use the following method1. load table into excel worksheet2. sort3. read it back into temp_data()the problem is the number of rows available in a singe worksheet ... 65536the table i facing may more than 65536 rowsi'm thinking of use excelApplication.WorksheetFunction to do it but i can't get it work...
 
User avatar
ExSan
Posts: 498
Joined: April 12th, 2003, 10:40 am

Vba sorting question

March 17th, 2006, 11:05 pm

send me a PM, I might help you.