make use of cell defined data validation in vba

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
 
B

Ben McClave

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top