I am wondering if there is a clean way to evaluate in-cell data validation. It could be either a length check or a drop-down list etc.
I can easily add data validation rules using the below code that validates if the entry is more than 5 characters in cell A1, but is there a way to evaluate it from inside VBA?
With Cells(1,1).DataBodyRange.Validation
.Delete
.Add Type:=xlValidateTextLength, AlertStyle:=xlValidAlertStop, _
Operator:=xlLess, Formula1:="6"
.ErrorTitle = "Too Many Characters"
.ErrorMessage = "The maximum allowed number of characters For this field is 5"
.ShowError = TRUE
End With
Validationobject for the range and sets properties for that object. In reverse, you can read the properties of an existing validation object, likeDebug.Print Cell.Validation.Formula1