+ Reply to Thread
Results 1 to 13 of 13

Custom data validation formula

Hybrid View

  1. #1
    Registered User
    Join Date
    03-21-2014
    Location
    West Midlands, UK
    MS-Off Ver
    Excel 2007
    Posts
    6

    Custom data validation formula

    I need a custom formula to validate data so as to limit it to two capital letters and then 1 to 3 integers. Data such as such as "DB1" or "OP100" would return true and be allowed in the cell.

  2. #2
    Forum Contributor
    Join Date
    01-30-2011
    Location
    Vancouver, Canada
    MS-Off Ver
    Excel 2010
    Posts
    604

    Re: Custom data validation formula

    This might do it -->

    See Column A attached.

    =AND(NOT(ISNUMBER(VALUE(LEFT(A1,1)))),NOT(ISNUMBER(VALUE(MID(A1,2,1)))), ISNUMBER(VALUE(RIGHT(A1,LEN(A1)-2))), LEN(A1)>=3, LEN(A1)<=5,EXACT(LEFT(A1,2),UPPER(LEFT(A1,2))))
    Attached Files Attached Files
    Last edited by Xx7; 03-23-2014 at 11:58 AM.

  3. #3
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,330

    Re: Custom data validation formula

    Hi Stan,

    Using what Xx7 did above and making it a little simpler, Try:

    =AND(NOT(ISNUMBER(VALUE(LEFT(A1,1)))),NOT(ISNUMBER(VALUE(MID(A1,2,1)))), ISNUMBER(VALUE(MID(a1,3,10))))
    Last edited by MarvinP; 03-23-2014 at 01:53 PM.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  4. #4
    Forum Contributor
    Join Date
    01-30-2011
    Location
    Vancouver, Canada
    MS-Off Ver
    Excel 2010
    Posts
    604

    Re: Custom data validation formula

    Hi Marvin, don't you need capitalization criteria and total string length criteria? Or can this be entered as separate validation criteria?

  5. #5
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,330

    Re: Custom data validation formula

    Hi Xx7,

    I simply used your first half of the data validation and took from character 3 to 10 and tried to see if it was all numbers. It made my formula a little shorter and allowed for 1 to 7 numbers after the first 2 letters. No UCASE involved with my formula.

  6. #6
    Registered User
    Join Date
    03-21-2014
    Location
    West Midlands, UK
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Custom data validation formula

    Thanks for the help guyz

  7. #7
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Custom data validation formula

    ...and another way

    Formula: copy to clipboard
    AND(AND(CODE(A1)>=65,CODE(A1)<=90),AND(CODE(MID(A1,2,1))>=65,CODE(MID(A1,2,1))<=90),VALUE(RIGHT(A1,3))<=999)
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  8. #8
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,651

    Re: Custom data validation formula

    Another option:
    =AND(ISERROR(--MID(A1,1,2)),--MID(A1,3,3)>0)
    Quang PT

  9. #9
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,330

    Re: Custom data validation formula

    Hi Quang,

    I was really hoping your answer would work. It needs to show false if the first two characters are not letters. I tries W31234 and it was allowed by your formula above. I think you are close to a better answer. Have another try?

  10. #10
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,651

    Re: Custom data validation formula

    Quote Originally Posted by MarvinP View Post
    Hi Quang,
    I was really hoping your answer would work. It needs to show false if the first two characters are not letters. I tries W31234 and it was allowed by your formula above. I think you are close to a better answer. Have another try?
    Thhanks Marvin, it was my failure. Maybe this works:
    =AND(ISERROR(--MID(A1,1,1)),ISERROR(--MID(A1,2,1)),--MID(A1,3,3)>=0)

  11. #11
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,330

    Re: Custom data validation formula

    Closer.

    I tried AB123A and it was ok. I don't think it should have been accepted. I reread the problem and he wants exactly two letter and then 1,2 or 3 digits.

    My formula didn't account for this second part either.

  12. #12
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,651

    Re: Custom data validation formula

    Good observation, Marvin. A lenght condition should be considered:

    =AND(ISERROR(--MID(A1,1,1)),ISERROR(--MID(A1,2,1)),--MID(A1,3,3)>=0,LEN(A1)<6)

  13. #13
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,651

    Re: Custom data validation formula

    Thank for the rep, Marvin.

    A B ###

    Test if first 2 are not numbers, next 3 are numbers with:

    ISERROR(--A),ISERROR(--B),--#,--#,--# = TRUE,TRUE,TRUE,TRUE,TRUE

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Data Validation - Custom Formula
    By Brandy in forum Excel General
    Replies: 5
    Last Post: 10-05-2009, 04:32 PM
  2. custom formula data validation
    By mwc0914 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-11-2008, 10:03 PM
  3. Data Validation Custom with Formula
    By bacalhoun in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-28-2007, 03:38 PM
  4. custom data validation formula
    By mpreddy in forum Excel General
    Replies: 4
    Last Post: 06-11-2007, 06:42 AM
  5. Data Validation - Custom - Formula
    By DYeomans in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-02-2005, 01:06 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1