Consulting

Results 1 to 3 of 3

Thread: Solved: Check if cell has data validation

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Master stanl's Avatar
    Joined
    Jan 2005
    Posts
    1,141
    Location

    Solved: Check if cell has data validation

    I've read some posts about this. Seems the only way to check is to create a function like HasValidation() which checks for the activecell.validation.type but has to generate an error to return False. Is there a cleaner way to determine validation. Stan

  2. #2
    Knowledge Base Approver VBAX Master Oorang's Avatar
    Joined
    Jan 2007
    Posts
    1,135
    Location
    Looking at the validation object, it would appear that's the only option. The validation object is instantiated it's just the properties will throw errors if you try to access them.
    Although it's worth noting that if the cell had validation and it has since been cleared, accessing the properties won't throw an error, so you also have to check to make sure the formula1 and formula2 properties (of the validation object) are empty.
    Another consideration is that if some cells in a range have validation and some do not, then an error will also be thrown, so each cell in the range has to be individually checked.
    Cordially,
    Aaron



    Keep Our Board Clean!
    • Please Mark your thread "Solved" if you get an acceptable response (under thread tools).
    • Enclose your code in VBA tags then it will be formatted as per the VBIDE to improve readability.

  3. #3
    VBAX Master stanl's Avatar
    Joined
    Jan 2005
    Posts
    1,141
    Location
    Thank you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •