Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

XL.Sheet.AutoFilter.SetSort

Sets the sorted column in AutoFilter by zero-based index and its sort order.

Component Version macOS Windows Linux Server iOS SDK
XL 7.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "XL.Sheet.AutoFilter.SetSort"; bookRef; sheetIndex; columnIndex { ; descending } )   More

Parameters

Parameter Description Example Flags
bookRef The reference to the workbook. Please use XL.LoadBook to load a file. $ref
sheetIndex The index of the sheet. This number ranges from 0 to XL.Book.SheetCount-1. 0
columnIndex The zero based column index. 0
descending Whether to sort descending.
Pass 0 for ascending and 1 for descending. Default is descending.
0 Optional

Result

Returns OK or error.

Description

Sets the sorted column in AutoFilter by zero-based index and its sort order.

Examples

Sort cell range with auto filter by two columns:

Set Variable [ $r ; Value: MBS( "XL.Sheet.AutoFilter"; $book; $sheet) ]
Set Variable [ $r ; Value: MBS( "XL.Sheet.AutoFilter.SetRef"; $book; $sheet; 2; 10; 1; 4) ]
Set Variable [ $r ; Value: MBS( "XL.Sheet.AutoFilter.SetSort"; $book; $sheet; 0) ]
Set Variable [ $r ; Value: MBS( "XL.Sheet.AutoFilter.AddSort"; $book; $sheet; 1) ]
Set Variable [ $r ; Value: MBS( "XL.Sheet.ApplyFilter"; $book; $sheet) ]

See also

This function checks for a license.

Created 22nd April 2017, last changed 28th June 2022


XL.Sheet.AutoFilter.SetRef - XL.Sheet.AutoFilter.SetTop10