make use of cell defined data validation in vba

  • Thread starter Thread starter cate
  • Start date Start date
C

cate

In vba, is there a way to exercise/engage the validation already
defined in a cell?? I have cells that have defined data rules but I
seem to be able to set cell values, in vba, to anything I please with
no error generated.

Thank you
 
Cate,

Try Range("A1").Validation.Value. From the help file:

"Returns a Boolean value that indicates if all the validation criteria are met (that is, if the range contains valid data)."

Thus, you could use the above property to check whether your changes are valid. If you capture the formula/value in a given range prior to making changes, then you could revert back to this original formula/value in the event that your code generates invalid data.

Ben
 
Back
Top