+ Reply to Thread
Results 1 to 11 of 11

Data Validation format length based on values in another cell

  1. #1
    Registered User
    Join Date
    09-02-2013
    Location
    SYd
    MS-Off Ver
    Excel 2003
    Posts
    13

    Data Validation format length based on values in another cell

    Hi
    Would like validation set in column M based on Column H values.
    In Column H values can be only "A" "B" or "C" ( have already set this as a list)

    If column H value = "A" or "B" then I want the use to enter a 5digit number in column M
    If Column H = "C" or blank then the user can enter any value

    thanks in advance

  2. #2
    Forum Expert
    Join Date
    02-19-2013
    Location
    India
    MS-Off Ver
    07/16
    Posts
    2,386

    Re: Data Validation format length based on values in another cell

    Hello rini11, Welcome to the forum. After selecting M1, you can enter following formula
    Go to data validation select custom and enter
    =AND(OR($H1="A",$H1="B"),LEN($M1)=5)
    Hope this helps !!
    If answer is resolving your query click " * " in left hand corner and mark thread as solved go to thread tool and select as solved

  3. #3
    Registered User
    Join Date
    09-02-2013
    Location
    SYd
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Data Validation format length based on values in another cell

    thanks for response.
    Formula works correctly if H1 = either "a" or "b" ( i can only enter 5 digit character in column M) however
    when the value in column H1 = "c" it is restricting me to 5 characters also . I want to be able to enter any value
    hope you can help

  4. #4
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Data Validation format length based on values in another cell

    Can the 5 digit number start with leading zeros?

    02345
    00345
    00045
    00005
    00000
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  5. #5
    Banned User!
    Join Date
    10-14-2006
    Posts
    1,211

    Re: Data Validation format length based on values in another cell

    Try this:

    DV

    =OR(AND(OR($H1="A",$H1="B"),LEN($M1)=5),$H1="C")

  6. #6
    Registered User
    Join Date
    09-02-2013
    Location
    SYd
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Data Validation format length based on values in another cell

    yes - can have preceding zero's in the 5 charachters

  7. #7
    Registered User
    Join Date
    09-02-2013
    Location
    SYd
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Data Validation format length based on values in another cell

    Teethless mama - your formula works better but does not allow preceding zeros's within the 5 length

  8. #8
    Forum Expert
    Join Date
    02-19-2013
    Location
    India
    MS-Off Ver
    07/16
    Posts
    2,386

    Re: Data Validation format length based on values in another cell

    Hello Rini ! use teethless mama formula but if you want to allow preceding zeros within 5 length, then add a single apostrophe like write '00000 instead of 00000 in Cell M1 for e.g. if you wanna type following type like
    Instead of
    Typing Type
    02345 '02345
    00345 '00345
    00045 '00045
    00005 '00005

    if answer helps click " * " (add Rep) in the left hand corner and mark thread as solved

  9. #9
    Registered User
    Join Date
    09-02-2013
    Location
    SYd
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Data Validation format length based on values in another cell

    thanks for pointing me in right direction - easier way was to format colM as text - validation now works and no need to enter leading apostrophe

  10. #10
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Data Validation format length based on values in another cell

    Quote Originally Posted by Teethless mama View Post

    =OR(AND(OR($H1="A",$H1="B"),LEN($M1)=5),$H1="C")
    Your formula fails and allows entries like:

    abcde
    1.345
    123.5
    1E+44
    Last edited by Tony Valko; 09-16-2013 at 09:06 AM.

  11. #11
    Forum Expert
    Join Date
    02-19-2013
    Location
    India
    MS-Off Ver
    07/16
    Posts
    2,386

    Re: Data Validation format length based on values in another cell

    Hello Tony Sir, if the cell H2 is formatted as text then i think formula =OR(AND(OR(H2="A",H2="B"),ISNUMBER(M2+0),LEN(M2)-(IF(ISERROR(FIND(".",M2)),0,10)+IF(ISERROR(FIND("+",M2)),0,10))=5),H2="C") will meet the requirement of number

    Thanks for pointing in that direction as everyone was trying to fix Len as 5 but forgot to consider number format,decimals and scientific part
    Last edited by hemesh; 09-17-2013 at 02:47 AM. Reason: posted wrong answer

+ 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. Replies: 3
    Last Post: 05-28-2013, 10:43 AM
  2. Replies: 10
    Last Post: 08-15-2012, 10:20 AM
  3. [SOLVED] Cell validation based on values
    By Grilleman in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-09-2012, 06:01 PM
  4. Format Values to specified length
    By kwiklearner in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-09-2006, 11:55 AM
  5. Data Validation based on range of values
    By jej1216 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-27-2006, 11:40 PM

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