When a password is entered...

jimmywanna

Board Regular
Joined
Mar 18, 2002
Messages
182
I have a macro which runs to make the user enter a password after a control button is pushed. It works perfectly, my only problem is when the password is entered the text being typed is visible. Is there any way of the text appearing as "******" or "XXXXXXX" so as anyone around cannot see the password?

thanks in advance guy's

jim

here is the macro:

Sub UNHIDEFORM()
'
' UNHIDEFORM Macro
' Macro recorded 30/01/2004 by gibsonj
'

'
Dim Pass, Msg As String
Dim Ans As Byte
Msg = "Wrong Password" & vbCrLf
Msg = Msg & "Try Again ?"
Password = "PRESLEY" ' Case sensitive
Pass = "xxx"

Do Until Pass = Password
Pass = InputBox("Enter Password", "Password")
If Pass = "" Then ActiveWorkbook.Close SaveChanges:=False
If Pass <> "PRESLEY" Then Ans = MsgBox(Msg, vbCritical + vbYesNo, "Password")
If Ans = vbNo Then ActiveWorkbook.Close SaveChanges:=False
Loop
Range("A1").Select

Columns("B:J").Select
Selection.EntireColumn.Hidden = False
Range("E2:F2").Select
End Sub
 
It all works a treat Richie, exept I need the bottom of the macro to be like this:
Private Sub CommandButton1_Click()

Const Password As String = "PRESLEY" ' Case sensitive
Dim Pass As String, Msg As String
Dim Ans As Integer

Msg = "Wrong Password" & vbCrLf & "Try Again ?"
Pass = TextBox1.Text

If Pass = "" Then ActiveWorkbook.Close SaveChanges:=False

If Pass <> "PRESLEY" Then
Ans = MsgBox(Msg, vbCritical + vbYesNo, "Password")
If Ans = vbNo Then
ActiveWorkbook.Close SaveChanges:=False
Else
TextBox1.Text = ""
TextBox1.SetFocus
End If
Else
Unload Me

End If
Columns("B:J").Select
Selection.EntireColumn.Hidden = False
Range("E2:F2").Select
End Sub

Now at the moment it unhides the columns anyway if a wrong password is entered and leaves Userform2 still needing a Password.

Am i right in thinking that it will need to be looped?

I tried this but apparently i didn't have a "do"

any help?

jim
 
Upvote 0

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
Wow! I am impressed!

I am sorry to push it but how about if I have a database and I want each employee to only see his/her data. Ie all staff need to enter the username and password. How do I go about that?

Thanks guys!
 
Upvote 0

Forum statistics

Threads
1,225,487
Messages
6,185,276
Members
453,285
Latest member
Wullay

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