Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

Remove-OfficeExcelNamedRange

Module
PSWriteOffice
Inputs
OfficeIMO.Excel.ExcelDocument

Removes a defined name.

Syntax

Remove-OfficeExcelNamedRange
[-Document <ExcelDocument>]
[-Global]
[-Name] <String>
[-PassThru]
[-Sheet <OfficeSheetSelector>]
[<CommonParameters>]
#
Parameter set: Default

Examples

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

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.