Validation object (Excel)
Represents data validation for a worksheet range.
Example
Use the Validation property of the Range object to return the Validation object. The following example changes the data validation for cell E5.
Range("e5").Validation _
.Modify xlValidateList, xlValidAlertStop, "=$A$1:$A$10"
Use the Add method to add data validation to a range and create a new Validation object. The following example adds data validation to cell E5.
With Range("e5").Validation
.Add Type:=xlValidateWholeNumber, _
AlertStyle:=xlValidAlertInformation, _
Minimum:="5", Maximum:="10"
.InputTitle = "Integers"
.ErrorTitle = "Integers"
.InputMessage = "Enter an integer from five to ten"
.ErrorMessage = "You must enter a number from five to ten"
End With
Methods
Properties
- AlertStyle
- Application
- Creator
- ErrorMessage
- ErrorTitle
- Formula1
- Formula2
- IgnoreBlank
- IMEMode
- InCellDropdown
- InputMessage
- InputTitle
- Operator
- Parent
- ShowError
- ShowInput
- Type
- Value
See also
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for