Macros/Calc/ba029/es

Summary
This page provides a LibreOffice Basic macro procedure that creates an advanced filter. It is an example drawn from Chapter 13 ("Calc as a Database") of the 7.0 Calc Guide.

Description
Applying an advanced filter with a macro works similarly to setting up a standard filter. The key difference is that the cell range containing the filter criteria is used to create the filter descriptor. The macro procedure below demonstrates how this is done using the createFilterDescriptorByObject method. It uses a class grade sheet in cells $Sheet1.A1:H11 as the data range and cells $Sheet2.A1:H3 as the criteria range. The linked spreadsheet contains such a data range and criteria range.

Code
This [[Media:Create_advanced_filter_with_macro.ods|Calc spreadsheet]] contains the above LibreOffice Basic code.