# Update-OfficeExcelText

Replaces text in cell values across a workbook, sheet or range.

Cmdlet 

**Module**

`PSWriteOffice`

**Inputs**

`OfficeIMO.Excel.ExcelDocument` `System.String[]`

**Source**

[UpdateOfficeExcelTextCommand.cs:35](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/PowerShell/PSWriteOffice/Sources/PSWriteOffice/Cmdlets/Excel/UpdateOfficeExcelTextCommand.cs#L35) 

Replaces text in cell values across a workbook, sheet or range.

## Syntax

```
Update-OfficeExcelText
[-CaseSensitive]
[-Document <ExcelDocument>]
[-PassThru]
[-Pattern] <String>
[-Range <String>]
[-Replacement] <String>
[-Sheet <OfficeSheetSelector[]>]
[-Show]
[-SimpleMatch]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
```

[#](#method-update-officeexceltext-switchparameter-exceldocument-switchparameter-string-string-string-officesheetselector-switchparameter-switchparameter-switchparameter-switchparameter)

Parameter set: `Document`

```
Update-OfficeExcelText
[-CaseSensitive]
[-PassThru]
[-Path] <String[]>
[-Pattern] <String>
[-Range <String>]
[-Replacement] <String>
[-Sheet <OfficeSheetSelector[]>]
[-Show]
[-SimpleMatch]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
```

[#](#method-update-officeexceltext-switchparameter-switchparameter-string-string-string-string-officesheetselector-switchparameter-switchparameter-switchparameter-switchparameter)

Parameter set: `Path`

```
Update-OfficeExcelText
[-CaseSensitive]
-LiteralPath <String[]>
[-PassThru]
[-Pattern] <String>
[-Range <String>]
[-Replacement] <String>
[-Sheet <OfficeSheetSelector[]>]
[-Show]
[-SimpleMatch]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
```

[#](#method-update-officeexceltext-switchparameter-string-switchparameter-string-string-string-officesheetselector-switchparameter-switchparameter-switchparameter-switchparameter)

Parameter set: `LiteralPath`

## Guides & Samples

Authored walkthroughs and practical samples linked to this command.

- [Update Existing Excel Workbooks](/docs/pswriteoffice/excel-update-existing/) Guide
  
  Replace values, edit rows, append table data, and make targeted workbook changes without rebuilding every sheet.

## Examples

### Replace text across a workbook

```powershell
Update-OfficeExcelText -Path .\Templates\Price-List.xlsx -Pattern 'Fabrikam Ltd' -Replacement 'Northwind Traders' -SimpleMatch
```

Replaces the old company name in every cell of the workbook and saves it.

### Rename hosts after a migration

```powershell
$changed = Update-OfficeExcelText -Path .\Reports\Inventory.xlsx -Sheet Servers, Services -Pattern '^SRV-(\d+)$' -Replacement 'NW-APP-$1' -PassThru
"Renamed $changed cells"
```

Uses a regular expression to rename the old SRV hosts to the new naming scheme on the inventory sheets and reports how many cells changed.

### Replace placeholders inside a block

```powershell
Open-OfficeExcel -Path .\Templates\Quote.xlsx {
    Update-OfficeExcelText -Pattern '{{Customer}}' -Replacement 'Northwind Traders' -SimpleMatch
    Update-OfficeExcelText -Pattern '{{Date}}' -Replacement (Get-Date -Format 'yyyy-MM-dd') -SimpleMatch
}
```

Fills a template and replaces its placeholder text in the same Open-OfficeExcel block.

## Parameters

**-CaseSensitive SwitchParameter optional**

Matches names and text using ordinal case sensitivity. Omission ignores case.

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

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

**-PassThru SwitchParameter optional**

Emits the native result after the operation.

**-Pattern String requiredposition: 1**

Date or DateTime number format pattern.

**-Range String optional**

A1 cell range on the selected worksheet.

**-Replacement String requiredposition: 2**

Replacement text or regular-expression replacement pattern.

**-Sheet OfficeSheetSelector[] optionalaliases: WorksheetName**

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

**-Show SwitchParameter optional**

Open the saved file in its registered application after a local block completes.

**-SimpleMatch SwitchParameter optional**

Uses literal text matching instead of regular expressions.

**-WhatIf SwitchParameter optional**

Shows what would happen if the command runs.

**-Confirm SwitchParameter optional**

Prompts for confirmation before running the command.

**-Path String[] requiredposition: 0pipeline: True (ByValue)aliases: FilePathsets: Path**

Workbook paths resolved with filesystem wildcard support.

**-LiteralPath String[] requiredpipeline: True (ByPropertyName)aliases: FullName, PSPathsets: LiteralPath**

Literal workbook paths, including FileInfo.FullName and provider PSPath.

## 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:904FE362C7AB41C004A1CC2B1408A8B25A32F860D405664251B9A7470DE8A3C3 -->
