Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
XL.Sheet.AutoFilter.AddFilter
Adds the filter value.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
XL | 7.3 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameters
Parameter | Description | Example |
---|---|---|
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 |
FilterColumnIndex | The column index of the filter. Range from 0 to XL.Sheet.AutoFilter.ColumnSize-1. |
$FilterColumn |
Filter | The filter value. |
Result
Returns OK or error.
Description
Adds the filter value.Examples
Add filters:
Set Variable [ $r ; Value: MBS( "XL.Sheet.AutoFilter.AddFilter"; $book; $sheet; 0; "Japan") ]
Set Variable [ $r ; Value: MBS( "XL.Sheet.AutoFilter.AddFilter"; $book; $sheet; 0; "USA") ]
Set Variable [ $r ; Value: MBS( "XL.Sheet.AutoFilter.AddFilter"; $book; $sheet; 0; "Switzerland") ]
Add filter with a list of values:
# AUTO FILTER: :: Applies the AutoFilter to the sheet
Set Variable [ $r ; Value: MBS( "XL.Sheet.AutoFilter"; $book; $sheet) ]
#
# Select Cells :: Sets the cell range of AutoFilter with header.
Set Variable [ $r ; Value: MBS( "XL.Sheet.AutoFilter.SetRef"; $book; $sheet; $headerRow; $lastRow; 4; 4 ) ]
#
# Add Filter :: Adds the filter values from a values list.
Set Variable [ $filterCount ; Value: ValueCount ( $FilterValues ) ]
Set Variable [ $filterIndex ; Value: 1 ]
Loop
Set Variable [ $filterValue ; Value: GetValue($filterValues; $filterIndex) ]
Set Variable [ $r ; Value: MBS( "XL.Sheet.AutoFilter.AddFilter"; $book; $sheet; 0; $filterValue) ]
#
# next
Set Variable [ $filterIndex ; Value: $filterIndex + 1 ]
Exit Loop If [ $filterIndex > $filterCount ]
End Loop
#
# Apply Filter :: Applies the AutoFilter to the sheet
Set Variable [ $r ; Value: MBS( "XL.Sheet.ApplyFilter"; $book; $sheet) ]
Use two filtered columns:
Set Variable [ $r ; Value: MBS( "XL.Sheet.AutoFilter"; $book; $sheet) ]
# pick area to use for filter
Set Variable [ $r ; Value: MBS( "XL.Sheet.AutoFilter.SetRef"; $book; $sheet; 2; 10; 1; 4) ]
# filter first column in the set
Set Variable [ $r ; Value: MBS( "XL.Sheet.AutoFilter.AddFilter"; $book; $sheet; 0; "USA") ]
Set Variable [ $r ; Value: MBS( "XL.Sheet.AutoFilter.AddFilter"; $book; $sheet; 0; "Japan") ]
# and filter second column in the reference area
Set Variable [ $r ; Value: MBS( "XL.Sheet.AutoFilter.AddFilter"; $book; $sheet; 1; "64") ]
# apply it!
Set Variable [ $r ; Value: MBS( "XL.Sheet.ApplyFilter"; $book; $sheet) ]
See also
- XL.Book.SheetCount
- XL.LoadBook
- XL.Sheet.AutoFilter
- XL.Sheet.AutoFilter.Clear
- XL.Sheet.AutoFilter.ColumnSize
- XL.Sheet.AutoFilter.Filter
- XL.Sheet.AutoFilter.FilterSize
- XL.Sheet.AutoFilter.FilterType
- XL.Sheet.AutoFilter.GetSort
- XL.Sheet.AutoFilter.SetRef
This function checks for a license.
Created 1st July 2017, last changed 11st November 2022