christianbiker
Active Member
- Joined
- Feb 3, 2006
- Messages
- 379
Hi all...I am trying to use various tools within VBA for users to create a password for a profile that they have. I do know that Excel isn't great for this type of security but it's the tool I have and the data isn't super sensitive. I was hoping I could use the INSTR function but can't seem to figure that out. The code I have so far is below and I would appreciate any assistance to force users to enter at least one number and one of the following symbols in the password textbox (ConfirmPassword): ! # $ % &
VBA Code:
Private Sub ChangePassword_Click()
Dim f As Range
Dim ws As Worksheet
Dim rng As Range
Dim answer As Integer
If UserName.Value = "" Or CurrentPassword.Value = "" Or Password.Value = "" Or ConfirmPassword.Value = "" Then GoTo 1
If Password.Value <> ConfirmPassword.Value Then GoTo 2
If Len(ConfirmPassword.Value) < 8 Then
MsgBox "Your new password must be a minimum of 8 characters in length."
Exit Sub
End If
With UserName
If .Value = "" Then
UserName.BackColor = vbYellow
MsgBox "You must select a client from the drop down box to continue. If the client you are looking for does not exist, a new profile will need to be added."
Exit Sub
End If
'2.Search "Sheet1", Column E2:E200000
Set f = Sheets("TIER ACCESS").Range("A3:A1502").Find(.Value, , xlValues, xlWhole, , , False)
If Not f Is Nothing Then
If Sheets("TIER ACCESS").Range("A" & f.Row) <> UserName.Value Then GoTo 3
If Sheets("TIER ACCESS").Range("B" & f.Row) <> CurrentPassword.Value Then GoTo 3
Sheets("TIER ACCESS").Range("B" & f.Row) = ConfirmPassword.Value
Else
MsgBox "No User Profile exists for this individual."
Exit Sub
End If
End With
MsgBox "Client Profile additions/modifications have been made."
Unload Me
Profile_Home.Show
Exit Sub
1:
If UserName.Value = "" Then UserName.BackColor = vbYellow
If CurrentPassword.Value = "" Then CurrentPassword.BackColor = vbYellow
If Password.Value = "" Then Password.BackColor = vbYellow
If ConfirmPassword.Value = "" Then ConfirmPassword.BackColor = vbYellow
MsgBox "All fields highlighted in yellow must be populated."
Exit Sub
2:
MsgBox "The new password fields do not match."
Exit Sub
3:
MsgBox "The Username and/or Current Password fields do not match what is currently on record."
Exit Sub
End Sub