# Set-OfficeExcelAutoFilter

Adds an AutoFilter to a range and applies filter conditions.

Cmdlet 

Aliases: ExcelAutoFilter

**Module**

`PSWriteOffice`

**Aliases**

`ExcelAutoFilter`

**Inputs**

`OfficeIMO.Excel.ExcelDocument`

**Source**

[SetOfficeExcelAutoFilterCommand.cs:44](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/PowerShell/PSWriteOffice/Sources/PSWriteOffice/Cmdlets/Excel/SetOfficeExcelAutoFilterCommand.cs#L44) 

Adds an AutoFilter to a range and applies filter conditions.

## Syntax

```
Set-OfficeExcelAutoFilter
[-Criteria <Hashtable>]
[-Document <ExcelDocument>]
[-PassThru]
[-Range] <String>
[-Sheet <OfficeSheetSelector>]
[<CommonParameters>]
```

[#](#method-set-officeexcelautofilter-hashtable-exceldocument-switchparameter-string-officesheetselector)

Parameter set: `Range`

```
Set-OfficeExcelAutoFilter
[-Between <Double[]>]
[-Contains <String>]
[-Document <ExcelDocument>]
[-DoesNotContain <String>]
[-EndsWith <String>]
[-GreaterThanOrEqual <Double>]
[-Header] <String>
[-LessThanOrEqual <Double>]
[-NotBetween <Double[]>]
[-NotEqual <Double>]
[-PassThru]
[-Range <String>]
[-Sheet <OfficeSheetSelector>]
[-StartsWith <String>]
[-Value <String[]>]
[<CommonParameters>]
```

[#](#method-set-officeexcelautofilter-double-string-exceldocument-string-string-double-string-double-double-double-switchparameter-string-officesheetselector-string-string)

Parameter set: `Condition`

## Guides & Samples

Authored walkthroughs and practical samples linked to this command.

- [Migrate from PSWriteExcel to PSWriteOffice](/docs/pswriteoffice/migrate-from-pswriteexcel/) Guide
  
  Replace archived PSWriteExcel scripts with maintained PSWriteOffice commands for XLSX creation, import, formulas, charts, and validation.

## Examples

### Add filter buttons to a range

```powershell
Open-OfficeExcel -Path .\Reports\Inventory.xlsx {
    ExcelSheet 'Servers' {
        ExcelAutoFilter A1:F500
    }
}
```

Adds AutoFilter drop-downs to the header row of A1:F500.

### Open a sheet filtered to the open work

```powershell
Open-OfficeExcel -Path .\Reports\Helpdesk.xlsx {
    ExcelSheet 'Tickets' {
        ExcelAutoFilter -Header Status -Value 'Open', 'On hold'
        ExcelAutoFilter -Header AgeDays -GreaterThanOrEqual 3
    }
}
```

Filters the ticket list to the Open and On hold statuses with at least three days of age, so the sheet opens on the work that needs attention.

### Filter a new range by header names

```powershell
Open-OfficeExcel -Path .\Reports\Helpdesk.xlsx {
    ExcelSheet 'Tickets' {
        ExcelAutoFilter A1:H900 -Criteria @{ Status = 'Open', 'On hold'; Region = 'EMEA' }
    }
}
```

Adds filter buttons and immediately shows only open EMEA tickets.

## Parameters

**-Criteria Hashtable optionalsets: Range**

Maps header names to filter values, value lists or comparison criteria.

**-Document ExcelDocument optionalpipeline: True (ByValue)**

Caller-owned workbook; omission uses the enclosing Excel content block.

**-PassThru SwitchParameter optional**

Emits the native result after the operation.

**-Range String required in Rangeposition: 0**

A1 cell range on the selected worksheet.

**-Sheet OfficeSheetSelector optional**

Worksheet name, one-based position or native worksheet object. Multi-sheet commands also accept wildcard names.

**-Between Double[] optionalsets: Condition**

Inclusive numeric range condition. Provide exactly two values: minimum, maximum.

**-Contains String optionalsets: Condition**

Text that the column value must contain.

**-DoesNotContain String optionalsets: Condition**

Text that the column value must not contain.

**-EndsWith String optionalsets: Condition**

Text that the column value must end with.

**-GreaterThanOrEqual Double optionalsets: Condition**

Numeric greater-than-or-equal condition.

**-Header String requiredposition: 0sets: Condition**

Header text identifying the target column.

**-LessThanOrEqual Double optionalsets: Condition**

Numeric less-than-or-equal condition.

**-NotBetween Double[] optionalsets: Condition**

Outside numeric range condition. Provide exactly two values: minimum, maximum.

**-NotEqual Double optionalsets: Condition**

Numeric not-equal condition.

**-StartsWith String optionalsets: Condition**

Text that the column value must start with.

**-Value String[] optionalsets: Condition**

Value or values consumed by the selected operation.

## Common Parameters

This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.

For more information, see [about_CommonParameters](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_commonparameters).

<!-- PowerForge markdown artifact sha256:E55ACD497C91ABDAB580979A1CF96C8086F9219F62C12018ACEA30F32A69FB5D -->
