# Set-OfficeExcelDataValidationMessage

Sets prompt and error messages on existing Excel data validation rules.

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 **727**

Forks **84**

Open issues **7**

Total downloads **5,275,783**

Release **OfficeIMO-v3.6.2**

Language: C# Updated: 2026-11-24

Cmdlet 

Aliases: ExcelDataValidationMessage

**Module**

`PSWriteOffice`

**Aliases**

`ExcelDataValidationMessage`

**Inputs**

`OfficeIMO.Excel.ExcelDocument`

**Outputs**

`System.Management.Automation.PSObject`

**Source**

[SetOfficeExcelDataValidationMessageCommand.cs:22](https://github.com/EvotecIT/PSWriteOffice/blob/main/Sources/PSWriteOffice/Cmdlets/Excel/SetOfficeExcelDataValidationMessageCommand.cs#L22) 

Sets prompt and error messages on existing Excel data validation rules.

## Syntax

```
Set-OfficeExcelDataValidationMessage
[-ErrorMessage <String>]
[-ErrorTitle <String>]
[-HeaderName <String>]
[-HeaderRow <Int32>]
[-IncludeHeader]
[-PassThru]
[-Prompt <String>]
[-PromptTitle <String>]
[-Range <String>]
[-Sheet <String>]
[-SheetIndex <Int32>]
[-ShowErrorMessage]
[-ShowInputMessage]
[-TableName <String>]
[<CommonParameters>]
```

[#](#method-set-officeexceldatavalidationmessage-string-string-string-int32-switchparameter-switchparameter-string-string-string-string-int32-switchparameter-switchparameter-string)

Parameter set: `Context`

```
Set-OfficeExcelDataValidationMessage
[-ErrorMessage <String>]
[-ErrorTitle <String>]
[-HeaderName <String>]
[-HeaderRow <Int32>]
[-IncludeHeader]
[-PassThru]
[-Path] <String>
[-Prompt <String>]
[-PromptTitle <String>]
[-Range <String>]
[-Sheet <String>]
[-SheetIndex <Int32>]
[-ShowErrorMessage]
[-ShowInputMessage]
[-TableName <String>]
[<CommonParameters>]
```

[#](#method-set-officeexceldatavalidationmessage-string-string-string-int32-switchparameter-switchparameter-string-string-string-string-string-int32-switchparameter-switchparameter-string)

Parameter set: `Path`

```
Set-OfficeExcelDataValidationMessage
-Document <ExcelDocument>
[-ErrorMessage <String>]
[-ErrorTitle <String>]
[-HeaderName <String>]
[-HeaderRow <Int32>]
[-IncludeHeader]
[-PassThru]
[-Prompt <String>]
[-PromptTitle <String>]
[-Range <String>]
[-Sheet <String>]
[-SheetIndex <Int32>]
[-ShowErrorMessage]
[-ShowInputMessage]
[-TableName <String>]
[<CommonParameters>]
```

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

Parameter set: `Document`

## Examples

### Add prompt and error text to a validation rule.

```powershell
$rules = Set-OfficeExcelDataValidationMessage -Path .\Report.xlsx -Sheet Data -HeaderName Sales -TableName ServiceHealth -PromptTitle 'Sales' -Prompt 'Enter 1-1000' -ErrorTitle 'Invalid sales' -ErrorMessage 'Enter a whole number from 1 to 1000' -ShowInputMessage -ShowErrorMessage -PassThru
$rules |
    Select-Object Range, PromptTitle, ErrorTitle
```

Updates validation metadata for matching rules and saves the workbook.

## Parameters

**-ErrorMessage String optionalaliases: Error**

Error message text. Omit or pass null to clear the message.

**-ErrorTitle String optional**

Error title. Omit or pass null to clear the title.

**-HeaderName String optionalaliases: ColumnName**

Header or table column name used to resolve the validation rules to update.

**-HeaderRow Int32 optional**

Worksheet header row used when resolving HeaderName without a table. Use 0 for the first row of the used range.

**-IncludeHeader SwitchParameter optional**

Include the header cell in the resolved range.

**-PassThru SwitchParameter optional**

Returns matching validation rules after updating them.

**-Prompt String optional**

Input prompt text. Omit or pass null to clear the prompt.

**-PromptTitle String optional**

Input prompt title. Omit or pass null to clear the title.

**-Range String optional**

A1 range used to select existing validation rules.

**-Sheet String optional**

Worksheet name to update. Defaults to the current DSL sheet.

**-SheetIndex Int32 optional**

Worksheet index (0-based) to update. Defaults to the current DSL sheet.

**-ShowErrorMessage SwitchParameter optional**

Forces Excel to show the validation error.

**-ShowInputMessage SwitchParameter optional**

Forces Excel to show the input prompt.

**-TableName String optional**

Optional table name for header-based range resolution.

**-Path String requiredposition: 0aliases: FilePath, InputPathsets: Path**

Workbook path to update.

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

Workbook to update outside the DSL context.

## 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:61B7644C8BD00EDC613BDDC7FB08AE41CC33A3028E1275940790287C1B69DD01 -->
