Hi to everyone,
first of all I must say thanks to all of them which has supported me so far to develop my (let me say...marvellous) excel file. However, I need your help again to introduce the last bit of code. I need to put a button which allows the user to change is password. To do this I have Sheet named users which contains Usernames on the first column, Passwords on the second column and Username again on the third column.
The code I developed so far is quite simple. First of all it recalls the username from another sheet and compares it with the entried password on the password change form. If this pass and the new password corresponds to the one inserted in the verification box the code has to carry on and change the old password value with the new one. It is at this stage that I generate an error since I do not know how to replace the old value with the new one in the excel sheet.
I post here the code hoping that you can help me to make it work.
first of all I must say thanks to all of them which has supported me so far to develop my (let me say...marvellous) excel file. However, I need your help again to introduce the last bit of code. I need to put a button which allows the user to change is password. To do this I have Sheet named users which contains Usernames on the first column, Passwords on the second column and Username again on the third column.
The code I developed so far is quite simple. First of all it recalls the username from another sheet and compares it with the entried password on the password change form. If this pass and the new password corresponds to the one inserted in the verification box the code has to carry on and change the old password value with the new one. It is at this stage that I generate an error since I do not know how to replace the old value with the new one in the excel sheet.
I post here the code hoping that you can help me to make it work.
Code:
Private Sub OK_Click()
Application.ScreenUpdating = False
Dim strUsername As String
Dim strOldPassword As String
Dim strNewPasswd As Variant
Dim strConfirmNewPasswd As Variant
Dim usr As Variant
Dim pwd As Variant
strUsername = Sheets("Step 1").Range("User").Text
usr = Application.VLookup(strUsername, Range("Username"), 2, False)
pwd = Application.VLookup(strOldPassword, Range("Password"), 2, False)
If IsError(usr) = False And IsError(strNewPasswd) = False Then
Sheets("Users").VLookup(strUsername, Range("Username"), 2, False).Value = strNewPasswd
Else
MsgBox "Errore nell'inserimento della nuova password. Verifica le password inserite"
Cancel = True
End If
Application.ScreenUpdating = True
End Sub