From The Document Foundation Wiki
< Macros‎ | Calc
Jump to navigation Jump to search

Template:TopMenu/en Template:Menu/en Template:Menu.Macros/en

Other languages:


This page provides a LibreOffice Basic macro procedure that removes the current sheet filter by setting an empty filter. It is an example drawn from Chapter 13 ("Calc as a Database") of the 7.0 Calc Guide.


When a filter is applied to a sheet, it replaces any existing filter for that sheet. Therefore, to remove a filter in a sheet, simply create and set an empty filter for that sheet (see code below).


1Sub RemoveSheetFilter()
2  Dim oSheet          ' Sheet to filter.
3  Dim oFilterDesc     ' Filter descriptor.
5  oSheet = ThisComponent.getSheets().getByIndex(0)
6  oFilterDesc = oSheet.createFilterDescriptor(True)
7  oSheet.filter(oFilterDesc)
8End Sub

This Calc spreadsheet contains the above LibreOffice Basic code.