Excel Sort Method

Alvaro

New Member
Hi all, i am using Excel 2000 and i am trying to call sort method

from progress... could anyone give me an example of doing it

without errors? First 3 rows of my Excel sheet are headers and my sort column will be "G".

I have tried it with errors...

orden = CHWORKSHEET:RANGE("A3:Z1000"):sort("C3",1,"",0,1,"",1,0,1,false,2,1).


Thanks very much,

Alvaro.
 

NickA

Member
I'm actually using Excel 97 (Not 2000) - although looking on MSDN the 'Sort' methods calling parameters haven't changed at all.

I would code the following...

CHWORKSHEET:Range("A3:Z1000"):Sort(
CHWORKSHEET:Range("G3"), /* Key1 */
1, /* Order1 */
, /* Key2 */
, /* Type */
, /* Order2 */
, /* Key3 */
, /* Order3 */
, /* Header*/
, /* OrderCustom */
, /* MatchCase */
, /* Orientation */
, /* SortMethod */
, /* IgnoreControlCharacters*/
, /* IgnoreDiacritics */
, /* IgnoreKashida */
).

The main difference I think is the use of a range object for 'Key1'. If you want to sort against column 'G', you should specify 'G3' as that is the cell containing the header for the row.

I would also try to determine the limits of the data before sorting rather than deciding on an arbitrary range of A3:Z1000. Excel provides a property called 'Cells' for obtaining a range using index numbers (EG Row 5 Column 2 = "B5"): If you know you've output 200 rows of data in 5 columns, you can get Excel to tell you what 'range' that is.

You might find it useful to do a sort via the menu options in Excel and record a macro as you go. You could then view the resulting VBScript to give you some pointers on the calling parameters required from Progress.
 
Top