Cmdlet
Remove-OfficeExcelNamedRange
Removes a defined name.
Syntax
Remove-OfficeExcelNamedRange
[-Document <ExcelDocument>]
[-Global]
[-Name] <String>
[-PassThru]
[-Sheet <OfficeSheetSelector>]
[<CommonParameters>]#Parameter set:
DefaultExamples
Remove a defined name
Open-OfficeExcel -Path .\Finance\Budget-2027.xlsx {
Remove-OfficeExcelNamedRange OldTaxRate
}Deletes the OldTaxRate name from the workbook.
Clean up names that no longer resolve
$broken = Get-OfficeExcelNamedRange -Path .\Finance\Budget-2027.xlsx | Where-Object Reference -like '*#REF!*'
Open-OfficeExcel -Path .\Finance\Budget-2027.xlsx {
foreach ($name in $broken) {
Remove-OfficeExcelNamedRange -Name $name.Name
}
}Removes every defined name that points to #REF! and saves the workbook.
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.
- -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.
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.