+ Reply to Thread
Results 1 to 13 of 13

VBA InputBox Password Validation

  1. #1
    Registered User
    Join Date
    07-17-2013
    Location
    Quezon City
    MS-Off Ver
    Excel 2010 and 2013
    Posts
    75

    VBA InputBox Password Validation

    I have a minor problem can someone help me to add more. Or make my code more simpler.

    I have a INPUTBOX that validates and accept as the following: When the user enter there password.
    Password
    *Have at least more than 4 characters
    *But not be more than 8 characters
    *Have at least 1 letter [Do not accept WHOLE numeric characters]


    This is the Problem my Password accept as the following but I DON'T WANT TO ACCEPT IT.
    *Add more
    *Password should not accept SPACES [NO SPACES]
    *Password should not accept SPECIAL CHARACTERS

    My latest code:
    Please Login or Register  to view this content.
    Why: To make it more professional
    Last edited by mcmunoz; 09-05-2013 at 10:26 PM.

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,767

    Re: VBA InputBox Password Validation

    Try this...

    Please Login or Register  to view this content.


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Registered User
    Join Date
    07-17-2013
    Location
    Quezon City
    MS-Off Ver
    Excel 2010 and 2013
    Posts
    75

    Re: VBA InputBox Password Validation

    Waaaa. I type the word simple .

    Always back in GoTo PasswordNotAcceptable

  4. #4
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: VBA InputBox Password Validation

    I'd do it like this, goTos are horrible It's also useful to let the user know what they've done wrong:
    Please Login or Register  to view this content.
    Though I think your logic is probably flawed, the only time password complexity means anything at all is when you set a password to open, there's no point in doing it anywhere else. Also, why do you not want to include special characters?

  5. #5
    Registered User
    Join Date
    07-17-2013
    Location
    Quezon City
    MS-Off Ver
    Excel 2010 and 2013
    Posts
    75

    Re: VBA InputBox Password Validation

    @Kyle - Why I don't like special characters because I don't know how to do the logic about it. I want to make my workbook protected. A macro that the user can protect there work and when a user opens it there is a password. Thanks for the code. It works. I will study more about it.

  6. #6
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: VBA InputBox Password Validation

    So you're setting a password to open with excel setting the prompt rather than a macro? You don't really want to be prompting for a password in your code as it's inherently insecure - anyone can bypass it. If you want to include special characters then just change:
    Please Login or Register  to view this content.
    To:
    Please Login or Register  to view this content.

  7. #7
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: VBA InputBox Password Validation

    Personally I would use a UserForm for entering a Password, where no one can see what is being typed in as the Password, only ****. Entering a Password via an InputBox, displays exactly what is being entered, without obscuring the actual characters, and just maybe someone may see it, and your Password is compromised.
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  8. #8
    Registered User
    Join Date
    07-17-2013
    Location
    Quezon City
    MS-Off Ver
    Excel 2010 and 2013
    Posts
    75

    Re: VBA InputBox Password Validation

    Quote Originally Posted by Kyle123 View Post
    So you're setting a password to open with excel setting the prompt rather than a macro? You don't really want to be prompting for a password in your code as it's inherently insecure - anyone can bypass it. If you want to include special characters then just change:
    I don't get your point Can you explain it more simpler.

    Thank you for your great help again.

  9. #9
    Registered User
    Join Date
    07-17-2013
    Location
    Quezon City
    MS-Off Ver
    Excel 2010 and 2013
    Posts
    75

    Re: VBA InputBox Password Validation

    Quote Originally Posted by Winon View Post
    Personally I would use a UserForm for entering a Password, where no one can see what is being typed in as the Password, only ****. Entering a Password via an InputBox, displays exactly what is being entered, without obscuring the actual characters, and just maybe someone may see it, and your Password is compromised.
    I really want to do that asterisk mark for password **** but I don't know using UserForm and a textbox and a button. Don't know how to call and end the process. And I only use BeforeDoubleClick the cell, that is all I know.

    Can you make a sample of that UserForm.

  10. #10
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: VBA InputBox Password Validation

    I don't really know haw to rephrase it any more explicitly. Excel code is not secure and worksheet protection is not secure, it is trivial to remove the protection put in place on these objects. AS such password strength is completely pointless. The only time a stronger password matters is when you require a password to open a workbook, this is set when saving. If that's what your doing, then all well and good - but why not just use the password box built into Excel when saving the workbook?

  11. #11
    Registered User
    Join Date
    07-17-2013
    Location
    Quezon City
    MS-Off Ver
    Excel 2010 and 2013
    Posts
    75

    Re: VBA InputBox Password Validation

    OMG. I forgot to know about that "Password built-in" in Excel when saving the workbook. Opening the workbook with password, Read-Only and Setting password are all there. But still there is 1 thing that password build-in cannot do. In my macro code there is a GUI that the user can protect sheets easily and the password is the same that will be set within this thread problem.

    I learned something again "Don't make things more complicated".

    By the way, can you add something more idea setting password that different to built-in.
    Last edited by mcmunoz; 09-05-2013 at 04:54 AM.

  12. #12
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: VBA InputBox Password Validation

    Then there's no point in making your password complicated - it doesn't matter how complicated you make a password due to how Excel stores it. - You can still easily set a password to lock a sheet from the protection options. Making it complicated also makes it more likely that your users will forget it and you'll have to find a way of unlocking their worksheet - it's one of those rare circumstances where you'd actually go for a simple password

  13. #13
    Registered User
    Join Date
    07-17-2013
    Location
    Quezon City
    MS-Off Ver
    Excel 2010 and 2013
    Posts
    75

    Re: VBA InputBox Password Validation

    Ok. Thank you for your advice and for your help. It helps me a lot realize and learn something.

    For now I will mark this thread as a solve. Thanks.

+ 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. Asterix when password entered into InputBox
    By adste89 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-29-2012, 10:59 AM
  2. Cancel Inputbox if Password string incorrect
    By Nu2Java in forum Excel General
    Replies: 1
    Last Post: 10-02-2012, 03:27 PM
  3. How to code Inputbox in password format
    By SMILE in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-28-2011, 07:50 AM
  4. InputBox Password
    By noodle48 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-28-2011, 08:18 AM
  5. How to allow multiple entries from a Password InputBox
    By carsto in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-07-2007, 06:41 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