jeffreysmith
08-07-2019, 07:24 AM
I'm new to this and this is my current VBA code but i want the password to be in asterisks instead of plain text. Please Help!
Sub Worksheet_Activate()
Const Passwrd As String = "TomBrady"
Dim sInput As Variant
Dim Attempt As Integer
Me.Protect Password:=Passwrd
Attempt = 1
Do
sInput = InputBox("Please enter the password for this sheet", "Password Required Attempt:" & Attempt)
If StrPtr(sInput) = 0 Then
'cancel pressed
Exit Do
ElseIf sInput = Passwrd Then ' Valid Password
Me.Unprotect Password:=Passwrd
Exit Do
Else
MsgBox "Invalid Password", 48, "Invalid"
Attempt = Attempt + 1
End If
Loop Until Attempt > 3 ' "Don't let the inputbox close if the password is not correct
End Sub
Sub Worksheet_Activate()
Const Passwrd As String = "TomBrady"
Dim sInput As Variant
Dim Attempt As Integer
Me.Protect Password:=Passwrd
Attempt = 1
Do
sInput = InputBox("Please enter the password for this sheet", "Password Required Attempt:" & Attempt)
If StrPtr(sInput) = 0 Then
'cancel pressed
Exit Do
ElseIf sInput = Passwrd Then ' Valid Password
Me.Unprotect Password:=Passwrd
Exit Do
Else
MsgBox "Invalid Password", 48, "Invalid"
Attempt = Attempt + 1
End If
Loop Until Attempt > 3 ' "Don't let the inputbox close if the password is not correct
End Sub