Cmdlet
Rename-OfficeExcelNamedRange
Renames a defined name.
Syntax
Rename-OfficeExcelNamedRange
[-Document <ExcelDocument>]
[-Global]
[-Name] <String>
[-NewName] <String>
[-PassThru]
[-Sheet <OfficeSheetSelector>]
[-ValidationMode <Sanitize| Strict>]
[<CommonParameters>]#Parameter set:
DefaultExamples
Rename a defined name
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
$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
- Caller-owned workbook; omission uses the enclosing Excel content block.
- -Global SwitchParameter
- Use workbook-global scope from inside the DSL.
- -Name String
- Named range name.
- -NewName String
- New named range name.
- -PassThru SwitchParameter
- Emits the native result after the operation.
- -Sheet OfficeSheetSelector
- Worksheet name, one-based position or native worksheet object. Multi-sheet commands also accept wildcard names.
- -ValidationMode ExcelDefinedNameValidationMode
- 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.