Excel Filter: Difference between revisions

From AutoIt Wiki
Jump to navigation Jump to search
(Created page with "== Set filer == ... == Retrieve all filtered rows == To retrieve all rows of a filtered range you need to work with Areas. An Area consists of one or multiple Ranges which yo...")
 
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Set filer ==
== Filter functions ==
...
Use one of the following functions to work with filters:
* '''_Excel_FilterGet:''' Returns a list of set filters
* '''_Excel_FilterSet:''' Sets/unsets filter definitions and filters the range


== Retrieve all filtered rows ==
== Retrieve all filtered rows ==
To retrieve all rows of a filtered range you need to work with Areas. An Area consists of one or multiple Ranges which you need to process in  aloop. The following example returns an array with all visible rows.
To retrieve all rows of a filtered range you need to work with Areas. An Area consists of one or multiple Ranges which you need to process in  a loop. The following example returns an array with all visible rows.
<syntaxhighlight lang="autoit">
<syntaxhighlight lang="autoit">
$oRange = $oWorkbook.ActiveSheet.Usedrange.SpecialCells($xlCellTypeVisible)
$oRange = $oWorkbook.ActiveSheet.Usedrange.SpecialCells($xlCellTypeVisible)

Latest revision as of 22:06, 1 February 2021

Filter functions

Use one of the following functions to work with filters:

  • _Excel_FilterGet: Returns a list of set filters
  • _Excel_FilterSet: Sets/unsets filter definitions and filters the range

Retrieve all filtered rows

To retrieve all rows of a filtered range you need to work with Areas. An Area consists of one or multiple Ranges which you need to process in a loop. The following example returns an array with all visible rows.

$oRange = $oWorkbook.ActiveSheet.Usedrange.SpecialCells($xlCellTypeVisible)
Local $aResult[1][$oRange.columns.Count], $aContent
; Read the data of all Ranges in the Area and concatenate the returned arrays.
For $oArea In $oRange.Areas
    $aContent = _Excel_RangeRead($oWorkbook, Default, $oArea, Default, True)
    _ArrayConcatenate($aResult, $aContent)
Next