+ Reply to Thread
Results 1 to 18 of 18

Disregard case in VBA code. (UCase, LCase, Select Case)

  1. #1
    Forum Contributor
    Join Date
    07-25-2012
    Location
    San Antonio, Texas
    MS-Off Ver
    Excel 2010
    Posts
    142

    Disregard case in VBA code. (UCase, LCase, Select Case)

    I'm working with some code I found online regarding passwords and logins within a userform. The issue I'm having is that the original code was specificly looking for uppercase inputs. There's only a few users that will be using the form, so I'd like to make this work with any case the user chooses. I just can't figure out how to remove it properly.

    Please Login or Register  to view this content.
    Any help is greatly appreciated.
    Thanks in advance!

    -Orestees

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Disregard case in VBA code. (UCase, LCase, Select Case)

    Hello Orestees,

    Change these 2 lines to make the user name and password case sensitive. Change the user names and passwords in the Select Case statement to what you want to use.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Contributor
    Join Date
    07-25-2012
    Location
    San Antonio, Texas
    MS-Off Ver
    Excel 2010
    Posts
    142

    Re: Disregard case in VBA code. (UCase, LCase, Select Case)

    I tried that before, but then I run into all sorts of problems. I've attached a demo file which should help. Thanks!

    -OresteesPasswordDemo.xlsm

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,803

    Re: Disregard case in VBA code. (UCase, LCase, Select Case)

    Some may not like this idea, but I've used the "Option Compare Text" statement (see VBA help for the option compare statement) to make all text comparisons case insensitive. Because it's a module level option, it will effect all procedures in your module, but, if you are certain you will never make a case-sensitive comparison, then this might be a workable option.

  5. #5
    Forum Contributor
    Join Date
    07-25-2012
    Location
    San Antonio, Texas
    MS-Off Ver
    Excel 2010
    Posts
    142

    Re: Disregard case in VBA code. (UCase, LCase, Select Case)

    That sounds like a very viable option for me MrShorty! How/where would this code work? Not familiar with it at all, sorry.

    -Orestees

  6. #6
    Forum Contributor
    Join Date
    07-25-2012
    Location
    San Antonio, Texas
    MS-Off Ver
    Excel 2010
    Posts
    142

    Re: Disregard case in VBA code. (UCase, LCase, Select Case)

    Sorry, just re-read your post, I'll take a look in the help section. I'll let you know if I run into any issues. Be right back.

    -Orestees

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

    Re: Disregard case in VBA code. (UCase, LCase, Select Case)

    you would put it at the top of the module but it is not needed here as your problem does not seem to exist-the original code converts all inputs to upper case before comparing them to upper case text, which makes the case the process case-insensitive
    Josie

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

  8. #8
    Forum Contributor
    Join Date
    07-25-2012
    Location
    San Antonio, Texas
    MS-Off Ver
    Excel 2010
    Posts
    142

    Re: Disregard case in VBA code. (UCase, LCase, Select Case)

    I thought that was what it was supposed to do, but every time I test it using lowercase passwords (either in the input, code, or both) I get denied access. I must really be doing something wrong, lol.

    -Orestees

  9. #9
    Forum Contributor
    Join Date
    07-25-2012
    Location
    San Antonio, Texas
    MS-Off Ver
    Excel 2010
    Posts
    142

    Re: Disregard case in VBA code. (UCase, LCase, Select Case)

    I tried using:
    Please Login or Register  to view this content.
    but to no avail.

    -Orestees

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

    Re: Disregard case in VBA code. (UCase, LCase, Select Case)

    what name and password did you enter? can you post a workbook-no data necessary?

  11. #11
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127

    Re: Disregard case in VBA code. (UCase, LCase, Select Case)

    I think Leith mentioned this, but changing the two lines of code with UCase should resolve.

    Please Login or Register  to view this content.
    You say you are running into problems. What problems are they?

  12. #12
    Forum Contributor
    Join Date
    07-25-2012
    Location
    San Antonio, Texas
    MS-Off Ver
    Excel 2010
    Posts
    142

    Re: Disregard case in VBA code. (UCase, LCase, Select Case)

    PasswordDemo.xlsm
    The only username and password set right now is "ADMIN", "ADMIN".
    I tried variations with uppercase and lowercase and didn't have an issue after adding in the Option Compare Text but when I tried adding in other usernames/passowrds, I ran into tons of issues.

    Thanks for hanging in with me here gang.

    -Orestees

  13. #13
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Disregard case in VBA code. (UCase, LCase, Select Case)

    Hello Orestees ,

    Here is a working example (case insensitive). If the inputs are converted to Upper Case then the strings in the Select Case must match.
    Please Login or Register  to view this content.

  14. #14
    Forum Contributor
    Join Date
    07-25-2012
    Location
    San Antonio, Texas
    MS-Off Ver
    Excel 2010
    Posts
    142

    Re: Disregard case in VBA code. (UCase, LCase, Select Case)

    I also tried taking away the UCase on both in the most recent file but still had issues.

    -Orestees

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

    Re: Disregard case in VBA code. (UCase, LCase, Select Case)

    as Leith said the UCase needs to be on both and then the strings you match to must be entered into the code in upper case.

  16. #16
    Forum Contributor
    Join Date
    07-25-2012
    Location
    San Antonio, Texas
    MS-Off Ver
    Excel 2010
    Posts
    142

    Re: Disregard case in VBA code. (UCase, LCase, Select Case)

    LEITH (or leith, lol) Thanks a ton. That worked no matter what combinations I used on it!
    Thanks everyone for your help. I was driving myself crazy all day yesterday.

    -Orestees

  17. #17
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Disregard case in VBA code. (UCase, LCase, Select Case)

    Hello Orestees,

    'S e do bheatha. Glad it is working.

  18. #18
    Forum Contributor
    Join Date
    07-25-2012
    Location
    San Antonio, Texas
    MS-Off Ver
    Excel 2010
    Posts
    142

    Re: Disregard case in VBA code. (UCase, LCase, Select Case)

    Go raibh míle maith agat Leith!

    -Orestees (Proud videographer for the San Antonio Gaelic Athletic Club) http://en.wikipedia.org/wiki/San_Ant..._Athletic_Club

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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