Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

Set-OfficeExcelDataValidationMessage

Aliases: ExcelDataValidationMessage
Module PSWriteOffice
Aliases
ExcelDataValidationMessage
Inputs
OfficeIMO.Excel.ExcelDocument
Outputs
System.Management.Automation.PSObject

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>]
#
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>]
#
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>]
#
Parameter set: Document

Examples

Authored help example

Add prompt and error text to a validation rule.

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