# Update-OfficeExcelText

Replaces text in worksheet values. Review available syntax, parameters, pipeline guidance, and reference details in PSWriteOffice API Reference.

Project

PSWriteOffice

PowerShell document automation across OfficeIMO's document, spreadsheet, presentation, PDF, Project, Access, EPUB, invoicing, and conversion engines.

[View on GitHub](https://github.com/EvotecIT/OfficeIMO/tree/master/PowerShell/PSWriteOffice) [Visit Website](#) [Releases](https://github.com/EvotecIT/PSWriteOffice/releases/tag/v3.0.5) [Changelog](#) [Get package](https://www.powershellgallery.com/packages/PSWriteOffice/0.2.0)

Stars **727**

Forks **84**

Open issues **7**

Total downloads **5,275,783**

Release **OfficeIMO-v3.6.2**

Language: C# Updated: 2026-11-24

Cmdlet 

Aliases: Replace-OfficeExcelText

**Module**

`PSWriteOffice`

**Aliases**

`Replace-OfficeExcelText`

**Inputs**

`OfficeIMO.Excel.ExcelDocument`

**Outputs**

`System.Int32`

**Source**

[UpdateOfficeExcelTextCommand.cs:24](https://github.com/EvotecIT/PSWriteOffice/blob/main/Sources/PSWriteOffice/Cmdlets/Excel/UpdateOfficeExcelTextCommand.cs#L24) 

Replaces text in worksheet values.

## Syntax

```
Update-OfficeExcelText
[-CaseSensitive]
-NewValue <String>
-OldValue <String>
[-Open]
[-PassThru]
[-Path] <String>
[-Range <String>]
[-Regex]
[-Sheet <String>]
[-SheetIndex <Int32>]
[<CommonParameters>]
```

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

Parameter set: `Path`

```
Update-OfficeExcelText
[-CaseSensitive]
-Document <ExcelDocument>
-NewValue <String>
-OldValue <String>
[-PassThru]
[-Range <String>]
[-Regex]
[-Sheet <String>]
[-SheetIndex <Int32>]
[<CommonParameters>]
```

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

Parameter set: `Document`

## Examples

### Replace status text and verify the update count.

```powershell
$count = Update-OfficeExcelText -Path .\Report.xlsx -Sheet Summary -OldValue Draft -NewValue Ready -PassThru
[pscustomobject]@{
    Path = '.\Report.xlsx'
    Replacements = $count
}
```

Updates matching text cells on a sheet, saves the workbook, and returns the replacement count.

## Parameters

**-CaseSensitive SwitchParameter optional**

Use case-sensitive matching.

**-NewValue String required**

Replacement text.

**-OldValue String required**

Text or pattern to replace.

**-Open SwitchParameter optionalaliases: Showsets: Path**

Open the file after saving when using -Path.

**-PassThru SwitchParameter optional**

Emit the object created or changed by the command.

**-Path String requiredposition: 0aliases: FilePath, InputPathsets: Path**

Workbook path to update.

**-Range String optional**

A1 range to update. Defaults to each selected worksheet's used range.

**-Regex SwitchParameter optional**

Treat -OldValue as a regular expression.

**-Sheet String optionalaliases: WorksheetName**

Worksheet name. Defaults to all sheets for path/document use and current sheet inside an ExcelSheet block.

**-SheetIndex Int32 optional**

Worksheet index when using a workbook object or path.

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

Workbook to update outside the DSL context.

## 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).

Evotec API Reference Copyright 2026 Evotec Services

<!-- PowerForge markdown artifact sha256:749C791A65BA24EEA1FA8E940869F98213A8816A40BDF783C90DF4346C2A4476 -->
