+ Reply to Thread
Results 1 to 22 of 22

Restricting entry to a combination of 7 letters

Hybrid View

  1. #1
    Registered User
    Join Date
    03-08-2013
    Location
    Lebanon
    MS-Off Ver
    Excel 2010
    Posts
    12

    Restricting entry to a combination of 7 letters

    Hello All,

    I want to restrict entry to cells to only 7 letters (combination thereof though each character can appear once). I have been using this formula successfully for 5 characters (=LEN(SUBSTITUTE((SUBSTITUTE((SUBSTITUTE((SUBSTITUTE((SUBSTITUTE(UPPER(R2),"R","",1)),"I","",1)),"E","",1)),"A","",1)),"F","",1))=0) though when i add another two characters (G and Y), the validation rules breaks down and doesn't validate anymore. I guess i am reaching the limits of the validation input formula.

    So any better way to do this, with VBA or another magic formula which can do the job.

    thanks,
    Ed

  2. #2
    Forum Contributor
    Join Date
    02-28-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    272

    Re: Restricting entry to a combination of 7 letters

    Pls attach the reference file

  3. #3
    Registered User
    Join Date
    03-08-2013
    Location
    Lebanon
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Restricting entry to a combination of 7 letters

    Book3.xlsx an example file

  4. #4
    Forum Contributor
    Join Date
    02-28-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    272

    Re: Restricting entry to a combination of 7 letters

    Kindly confirm you want a validation wherein if cell value is without (RIEAFGY) then only it allows me to enter the word

  5. #5
    Registered User
    Join Date
    03-08-2013
    Location
    Lebanon
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Restricting entry to a combination of 7 letters

    Yes, in need of a validation rule where you can only enter any combination of the 7 letters (without replacement). Thus only allowing entry of combination of the 7 letter. e.g. r; eag; ygfaeir; are all valid entries wheres these are not: any letter not in the combination: rp; efgh....etc and if one of the letters is repeated in the entry e.g. rre is not valid since r appears twice.
    hope this clarifies, thanks.

  6. #6
    Forum Contributor
    Join Date
    02-28-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    272

    Re: Restricting entry to a combination of 7 letters

    There u go.....
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    03-08-2013
    Location
    Lebanon
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Restricting entry to a combination of 7 letters

    Hey, thanks for your input on this.

    Though the problem is still that one is able to enter combination of permitted letters with non-permitted, e.g.: ro; rp..etc are being accepted by the rule. In addition the rule is also permitting the input of the same letter more than once.


  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Restricting entry to a combination of 7 letters

    Perhaps instead,

    =AND(ISNUMBER(FIND(MID(C7, ROW(INDIRECT("1:7")), 1), "AEFGIRY")), LEN(SUBSTITUTE(C7, MID(D11, ROW(INDIRECT("1:7")), 1), "")) >= LEN(C7) - 1)
    Entia non sunt multiplicanda sine necessitate

  9. #9
    Registered User
    Join Date
    03-08-2013
    Location
    Lebanon
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Restricting entry to a combination of 7 letters

    Hmm thanks shg, though it doesn't detect the fault entries with the correct entries. e.g. RIu is accepted by the formula....

  10. #10
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Restricting entry to a combination of 7 letters

    Typo:

    =AND(ISNUMBER(FIND(MID(C7, ROW(INDIRECT("1:7")), 1), "AEFGIRY")),
    LEN(SUBSTITUTE(C7, MID(C7, ROW(INDIRECT("1:7")), 1), "")) >= LEN(C7) - 1)

  11. #11
    Registered User
    Join Date
    03-08-2013
    Location
    Lebanon
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Restricting entry to a combination of 7 letters

    still...Accepts any wrong entry if there is already a correct entry letter, such as: iu; where i s ok but not u. In addition, repeated entries are also permitted - which shouldn't be, e.g.: eafgg (though it captures single letter repeated entries: ggg) .

  12. #12
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Restricting entry to a combination of 7 letters

    there's gotta be a simpler solution but I reckon this works

    =AND(LEN(C7)<8,MAX(FREQUENCY(MATCH(MID(C7,ROW(INDIRECT("1:"&LEN(C7))),1),$H$1:$N$1,0),MATCH(MID(C7,ROW(INDIRECT("1:"&LEN(C7))),1),$H$1:$N$1,0)))=1,COUNT(MATCH(MID(C7,ROW(INDIRECT("1:"&LEN(C7))),1),$H$1:$N$1,0))=LEN(C7))
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  13. #13
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Restricting entry to a combination of 7 letters

    Are we looking at the same thing?

    In the examples below, the validation formula is in the adjacent cell.

          --A-- --B--
      1   EAFGG FALSE
      2   EE    FALSE
      3   IU    FALSE
      4   EAFG   TRUE
    You are using this for data validation, correct? If it's entered in a cell, it MUST be confirmed with Ctrl+Shift+Enter.
    Last edited by shg; 03-14-2013 at 10:32 AM.

  14. #14
    Registered User
    Join Date
    03-08-2013
    Location
    Lebanon
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Restricting entry to a combination of 7 letters

    --A-- --B--
    1 EAFGG FALSE > Correct: Since G is repeated twice
    2 EE FALSE> Correct since EE is repeated twice
    3 IU FALSE> Correct since U is not one of the 7 letters
    4 EAFG TRUE> Correct: Since all are from the 7 letters and inputted once.

  15. #15
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Restricting entry to a combination of 7 letters

    I know they are correct; what I'm missing is why you say it doesn't work.

    Also, the formula is case-sensitive, so all of the examples you gave in post #5 would fail.

  16. #16
    Registered User
    Join Date
    03-08-2013
    Location
    Lebanon
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Restricting entry to a combination of 7 letters

    =AND(ISNUMBER(FIND(MID(C7, ROW(INDIRECT("1:7")), 1), "AEFGIRY")),LEN(SUBSTITUTE(C7, MID(C7, ROW(INDIRECT("1:7")), 1), "")) >= LEN(C7) - 1)

    The above formula returns "AEE" as True, where it should be false since EE is entered twice.

  17. #17
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Restricting entry to a combination of 7 letters

    it returns false if you array-enter it as stated by shg

  18. #18
    Registered User
    Join Date
    03-08-2013
    Location
    Lebanon
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Restricting entry to a combination of 7 letters

    How do you do that in a validation formula box?

  19. #19
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Restricting entry to a combination of 7 letters

    you don't have to in a dv box-it's automatic-and that formula works for me as a dv source

  20. #20
    Registered User
    Join Date
    03-08-2013
    Location
    Lebanon
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Restricting entry to a combination of 7 letters

    Great!!! Many thanks guys really for the time, believe me this is for a better cause. I added upper(), so now it work for lower case as well.

    =AND(ISNUMBER(FIND(MID(UPPER(P7), ROW(INDIRECT("1:7")), 1), "AEFGIRY")),LEN(SUBSTITUTE(UPPER(P7), MID(UPPER(P7), ROW(INDIRECT("1:7")), 1), "")) >= LEN(P7) - 1)

    best,
    ED

  21. #21
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Restricting entry to a combination of 7 letters

    Or just replace FIND with SEARCH.

  22. #22
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Restricting entry to a combination of 7 letters

    you'll still need upper for the substitute function to work though

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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