Consulting

Results 1 to 2 of 2

Thread: Solved: Data Validation based on multiple criteria

  1. #1

    Solved: Data Validation based on multiple criteria

    I am attempting to set validation on a cell based on 2 criteria.
    The user can either input data into a cell but it must meet the following format:-

    AB123456C (i.e. 2 letters, 6 numbers then a letter) or 12/03/1967 (i.e a date of birth using the "/" as a separator.

    Any other format is not allowed as a VLOOKUP is used based on what is input to this cell.

    I have looked at using a formula in Data>Validation and cannot work it out.

    Is there such a formula or any VBA which would do it?
    TIA

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Dates do not contain the / characters and so on, that is just a view. They are just numbers, how they are input depends upon the format.

    So, all you need is

    =OR(AND(LEN(C12)=9,NOT(ISNUMBER(--LEFT(C12,2))),ISNUMBER(--MID(C12,3,6)),NOT(ISNUMBER(--RIGHT(C12,1)))),AND(ISNUMBER(C12)))
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

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