Change Password VBA code

Runner11

New Member
Joined
Jul 23, 2014
Messages
8
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.

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
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Essentially what I need (I guess) is something which uses the match function. If we can find the way to return the cell number (for example b8) when the password is found. I can assign a costant to the found cell and at that point change the value of the cell with the new password.
How can I do this with Match starting from a UserForm?
 
Upvote 0
Re: Change Password VBA code SOlved!!

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.

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

Solved!
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,967
Members
452,371
Latest member
Frana

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