PreviousNext
Help > Programming with LAUNCHER Office > LNCCMD commands > Commands list > XLSORT command
XLSORT command

Allows you to sort the cells of a sheet according to one or more columns.

 Syntax

 

CHGVAR

VAR(&CMD) VALUE('XLSUBTOTAL')

CHGVAR

VAR(&PARM1) VALUE('
[;Sheet="Sheet name"]
[;Key1=cell]
[;Order1=xlDescending/xlAscending]
[;Key2=cell]
[;Order2=xlDescending/xlAscending]
[;Key3=cell]
[;Order3=xlDescending/xlAscending]
[;Header=xlYes/xlNo]
')

CHGVAR

VAR(&PARM2) VALUE(' ')

CALL

PGM(LNCCMD) PARM(&HANDLE &CMD &OPT &PARM1 +

&PARM2 &RESULT)

 

Parameters

 

Parameters

 

Parm1


Sheet
: Specifies the name of the sheet to process.
If the Sheet keyword is missing, the active sheet is taken into account.

All cells in the sheet will be sorted.

Key1, Key2, Key3: Coordinates of the 1st cell of the column from which you want to sort.
The coordinates of the cell can be given in the form:
- Syntax $B$3. Example: $ B $ 3 is column B, line 3.
- Syntax CL. C to designate the column and L to designate the line. Example: B3 designates line 3, and column 2 (B).
- Symbolic name.

Key1 will be the priority sort order, followed by Key2 and Key3.

 

Order1, Order2, Order3: Sort order. Corresponds to Key1, Key2 and Key3 respectively. The values ​​can be:
xlDescending: Descending order of values.
xlAscending: ascending order of values.
Default value: xlAscending.

Header: Specifies whether the sheet contains a row of column headers, so that it does not form part of the sort.
xlYes: the sheet contains a row of column headers, and we want to exclude this line from sorting.
xlNo: the sheet does not contain header lines, or we want the header line to be part of the sort. Default value.

 

 

 

Example

 

We want to sort the cells of the active sheet according to the values of column H (decreasing values), and then, the result of this first sorting will be ordered according to the values of column A (increasing values).

The first row of column headers will not be taken into account for sorting.

 

     LNCCMD     CMD(EXCELOPEN) +                                      

                  PARM1('C:\A\sp_cust_ref.xlsx') +                    

                  PARM2('visible')

                                   

     LNCCMD     CMD(XLSORT) +                                         

               PARM1('Key2="$A$2";Order2=xlAscending;Key1=+        

               "$H$2";Order1=xlDescending;Header=xlYes')