# Set-OfficeExcelNamedRange

Creates or updates a named range. 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 **725**

Forks **84**

Open issues **3**

Total downloads **5,231,343**

Release **OfficeIMO-v3.6.2**

Language: C# Updated: 2026-11-23

Cmdlet 

Aliases: ExcelNamedRange

**Module**

`PSWriteOffice`

**Aliases**

`ExcelNamedRange`

**Inputs**

`OfficeIMO.Excel.ExcelDocument`

**Source**

[SetOfficeExcelNamedRangeCommand.cs:18](https://github.com/EvotecIT/PSWriteOffice/blob/main/Sources/PSWriteOffice/Cmdlets/Excel/SetOfficeExcelNamedRangeCommand.cs#L18) 

Creates or updates a named range.

## Syntax

```
Set-OfficeExcelNamedRange
[-Global]
[-Hidden]
[-Name] <String>
[-PassThru]
[-Range] <String>
[-Save]
[-ValidationMode <Sanitize|Strict>]
[<CommonParameters>]
```

[#](#method-set-officeexcelnamedrange-switchparameter-switchparameter-string-switchparameter-string-switchparameter-exceldefinednamevalidationmode)

Parameter set: `Context`

```
Set-OfficeExcelNamedRange
-Document <ExcelDocument>
[-Hidden]
[-Name] <String>
[-PassThru]
[-Range] <String>
[-Save]
[-Sheet <String>]
[-SheetIndex <Int32>]
[-ValidationMode <Sanitize|Strict>]
[<CommonParameters>]
```

[#](#method-set-officeexcelnamedrange-exceldocument-switchparameter-string-switchparameter-string-switchparameter-string-int32-exceldefinednamevalidationmode)

Parameter set: `Document`

## Description

Defaults to the current sheet scope when used inside the Excel DSL.

## Examples

### Define a named range inside a sheet.

```powershell
ExcelSheet 'Data' { Set-OfficeExcelNamedRange -Name 'Totals' -Range 'B2:B50' }
```

Creates a sheet-scoped name for the range.

## Parameters

**-Global SwitchParameter optionalsets: Context**

Force a workbook-global name even inside a sheet block.

**-Hidden SwitchParameter optional**

Mark the defined name as hidden.

**-Name String requiredposition: 0**

Name of the defined range.

**-PassThru SwitchParameter optional**

Emit the name after creation.

**-Range String requiredposition: 1**

Range in A1 notation.

**-Save SwitchParameter optional**

Save the workbook immediately after setting the name.

**-ValidationMode ExcelDefinedNameValidationMode optional**

Validate or sanitize the defined name.

Possible values: `Sanitize`, `Strict`

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

Workbook to operate on outside the DSL context.

**-Sheet String optionalsets: Document**

Worksheet name when using Document.

**-SheetIndex Int32 optionalsets: Document**

Worksheet index (0-based) when using Document.

## 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:9574DC11110BE7C5B4B55FAE7439510B0C9AA552504E1418D7A37A1A3BEF0359 -->
