Userform Password

Mkammari

Board Regular
Joined
Nov 23, 2005
Messages
65
I have a main menu userform(VBA) that has security considerations(minor security). I have a command button for Administrative, that will unhide sheets and allow the person to make certain changes to a database. Does anyone know of a simple code to ask for a password to all the user access to the worksheet...and to disallow if the password is incorrect.
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
This may be a start:

<font face=tahoma><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> CommandButton1_Click()
    <SPAN style="color:#00007F">Dim</SPAN> pw <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>
    <SPAN style="color:#00007F">Dim</SPAN> ans <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>
    
        pw = "yada"
        ans = InputBox("Please enter the Password", "*****")
        
        <SPAN style="color:#00007F">If</SPAN> ans = pw <SPAN style="color:#00007F">Then</SPAN>
            Sheets("Sheet1").Visible = <SPAN style="color:#00007F">True</SPAN>
        <SPAN style="color:#00007F">Else</SPAN>
            Sheets("Sheet1").Visible = <SPAN style="color:#00007F">False</SPAN>
            MsgBox "Incorrect Password", vbInformation + vbOKOnly, "Buh Bye"
        <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN>
        
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

Hope that helps,

Smitty
 

Mkammari

Board Regular
Joined
Nov 23, 2005
Messages
65
Hiding the password

Is there anyway to make the password hidden? For example, have it show up as *****...rather than a visible word?
 

Smitty

Legend
Joined
May 15, 2003
Messages
29,536

ADVERTISEMENT

You can create a Password Input UserForm and set its Password Character property to "*****".

It only takes a ferw minutes more and it's still seamless to the user.

Smitty
 

Sprucy

Board Regular
Joined
Oct 31, 2005
Messages
92
Question!

Hey guys,

Can I set multiple passwords?
I've posted a similar question and no one could help.

I would like about 60 usernames with 60 passwords.
Once I've got that, I will need to code something like..
For all changes made on sheet, add username into Z

So, if Tom Waits (psswrd 10) log's in,
and makes changes to A1, A5, B6, C7,
Cells Z1, Z5, Z6 & Z7 would show Tom Waits

Does this make sense?
 

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
Sure,

It's easiest on a hidden sheet with a column for user name and another one for password.

If you PM me your e-mail address I'll send you a workbook that shows how to do it.

Smitty
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,059
Messages
5,835,166
Members
430,343
Latest member
t0m_c

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top