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

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
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
 
Upvote 0
Hiding the password

Is there anyway to make the password hidden? For example, have it show up as *****...rather than a visible word?
 
Upvote 0
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
 
Upvote 0
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?
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,213,561
Messages
6,114,316
Members
448,564
Latest member
ED38

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
Back
Top