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

Enables you to apply a row grouping function on columns in a selection. 

 

Syntax

 

CHGVAR

VAR(&CMD) VALUE('XLSUBTOTAL')

CHGVAR

VAR(&PARM1) VALUE('
TotalList="list"

[;Ref=" Selected cell reference"]
[;Sheet="Sheet name"]
[;RefTo="End of selected area reference"]
[;GroupBy=
Rank of column]
[;Function=Function code]
[;Replace=True/False]
[;PageBreaks=True/False]
[;SummaryBelowData=xlSummaryAbove/xlSummaryBelow]
')

CHGVAR

VAR(&PARM2) VALUE(' ')

CALL

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

&PARM2 &RESULT)

 

Parameters

 

Paramètres

 

Parm1


TotalList: List of the numbers of the columns on which the function is to be applied (Function parameter).
The columns are numbered from 1 to n.
The numbers are separated by the character "semicolon", in a double-quoted list. Mandatory.

Ref: The reference of the area to be treated.
1) Either we specify the name of the zone.
2) Either we specify the reference of the cell at the top left of the area to resize.
The cell reference at the top left can be given as:
- Syntax $B$3. Example: $B$3 is column B, row 3.
- Syntax CL. C to designate the column and L to designate the row. Example: B3 designates row 3, and column 2 (B).
- Symbolic name.
In this case, RefTo is used to specify the reference of the cell at the bottom right of the area to be treated.

If Ref is absent, all cells in the sheet will be processed.

Sheet: Specifies the name of the sheet to be processed.
If Sheet is missing, the active sheet will be processed.

RefTo: Reference to the cell at the bottom right of the selected area. This reference is given in the form:
- Syntax $B$3. Example: $B$3 is column B, row 3.
- Syntax CL. C to designate the column and L to designate the row. Example: B3 designates row 3, and column 2 (B).
- Symbolic name.

GroupBy: This option specifies the rank of the column to use to group summation. The columns are numbered from 1 to n.
Default value = 1.

Function: Designates the function to apply.
The possible values
​​are:
xlAverage, xlCount, xlCountNums, xlMax, xlMin, xlProduct, xlStDev, xlStDevP, xlSum, xlUnknown, xlVar, xlVarP.
See the
Microsoft Excel documentation for more details on these features.
Default value: xlSum.

Replace: False not to replace the current subtotals.
By default, subtotals are replaced (True).

PageBreaks: To add a page break after each group.
Default value: False.

SummaryBelowData: Allows you to choose the position of subtotals.
The possible values
​​are:
xlSummaryAbove to place subtotals before each data group.
xlSummaryBelow (Default) to place the subtotals after the group hits.

 

 

Example

 

In the following example, subtotals are created for column 12, with groupings made based on columns 1 and 6.

All the cells of the "data" sheet are taken into account.

PGM

                                                         
LNCOPEN


LNCCMD CMD(EXCELOPEN)


LNCCMD CMD(XLOPENFILE) PARM1('C:\A\DataRef.XLSX')


LNCCMD CMD(XLGOTOSH) PARM1('data')


LNCCMD CMD(XLSUBTOTAL) + 
PARM1('sheet="data";GroupBy=1;Function=xlSu+ 
m;TotalList="12"')


LNCCMD CMD(XLSUBTOTAL) + 
PARM1('sheet="data";GroupBy=6;Function=xlSu+ 
m;TotalList="12";REPLACE=FALSE')


LNCCMD CMD(XLSAVEAS) + 
PARM1('C:\A\RES.XLSX;replace=true')


LNCCMD CMD(EXCELCLOSE)


LNCCLOSE


ENDPGM 

 

To apply subtotals only on a selection of cells, you can use the following command:

 

  LNCCMD     CMD(XLSUBTOTAL) +                             

               PARM1('Ref="A1";RefTo="N14";sheet="data";Gr+

               oupBy=1;Function=xlSum;TotalList="12"')