# Rename-OfficeExcelNamedRange

Renames a defined name. Review available syntax, parameters, pipeline guidance, and reference details in PSWriteOffice Cmdlet Reference.

Cmdlet 

**Module**

`PSWriteOffice`

**Inputs**

`OfficeIMO.Excel.ExcelDocument`

**Source**

[RenameOfficeExcelNamedRangeCommand.cs:32](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/PowerShell/PSWriteOffice/Sources/PSWriteOffice/Cmdlets/Excel/RenameOfficeExcelNamedRangeCommand.cs#L32) 

Renames a defined name.

## Syntax

```
Rename-OfficeExcelNamedRange
[-Document <ExcelDocument>]
[-Global]
[-Name] <String>
[-NewName] <String>
[-PassThru]
[-Sheet <OfficeSheetSelector>]
[-ValidationMode <Sanitize|Strict>]
[<CommonParameters>]
```

[#](#method-rename-officeexcelnamedrange-exceldocument-switchparameter-string-string-switchparameter-officesheetselector-exceldefinednamevalidationmode)

Parameter set: `Default`

## Examples

### Rename a defined name

```powershell
Open-OfficeExcel -Path .\Finance\Budget-2027.xlsx {
    Rename-OfficeExcelNamedRange Rate TaxRate
}
```

Renames Rate to TaxRate; formulas that use the name follow the change.

### Apply a naming convention

```powershell
$names = Get-OfficeExcelNamedRange -Path .\Finance\Pricing-Model.xlsx | Where-Object SheetName -eq 'Inputs'
Open-OfficeExcel -Path .\Finance\Pricing-Model.xlsx {
    foreach ($name in $names) {
        Rename-OfficeExcelNamedRange -Name $name.Name -NewName "in_$($name.Name)" -ValidationMode Strict
    }
}
```

Prefixes every input name of the pricing model with in_ so inputs are easy to tell apart from calculations.

## Parameters

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

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

**-Global SwitchParameter optional**

Use workbook-global scope from inside the DSL.

**-Name String requiredposition: 0**

Named range name.

**-NewName String requiredposition: 1**

New named range name.

**-PassThru SwitchParameter optional**

Emits the native result after the operation.

**-Sheet OfficeSheetSelector optional**

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

**-ValidationMode ExcelDefinedNameValidationMode optional**

Defined-name validation mode.

Possible values: `Sanitize`, `Strict`

## 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:1806654887043942CC846ED075B09747A2D77509AB558B5A8BAB585960D1AAF2 -->
