ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Change Password from an Array (https://www.excelbanter.com/excel-programming/381150-change-password-array.html)

spences10

Change Password from an Array
 
Hi,

I have devised a UserForm that asks for a username and password which
in turn unlocks certain parts of a work book for that user, I want to
enable them to change the password that has been assigned to them.

I am currently trying to use InputBox method for this, with some degree
of success where I can populate the sheet with the passwords on it, but
not for each individual user. So what I think I need is a way to look
up who the user is in the array then change the password for that user.


Tom Ogilvy

Change Password from an Array
 
You said inputbox, but unless you want to show a series of inputboxes, I
would use a userform such as below
Assume the username is in Textbox1 and the usernames are listed in Sheet10
starting in A1 and current corresponding passwords in column B

Textbox2: Old Password
Textbox3: New Password
Textobx4: New Password (confirmation)

Private Sub CommandButton1_Click()
Dim rng as Range
Dim res as Variant
With worksheets("Sheet1")
set rng = .Range(.Cells(1,1),Cells(1,1).End(xldown))
end with
res = Application.Match(Textbox1.Value,rng,0)
if not iserror(res) then
if rng(res).offset(0,1).Value = Textbox2.Text then
if Textbox3.Value = Textbox4.Value then
rng(res).offset(0,1).Value = Textbox3.Value
Activeworkbook.Save
msgbox "Password Changed
else
msgbox "Passwords do not match"
exit sub
end if
else
msgbox "Orignal password incorrect"
exit sub
end if
Else
msgbox "Invalid user id"
exit sub
end if
End Sub

If you still want to use inputboxes, then the above should give you the
basics with which you can integrate inputbox promts..

--
Regards,
Tom Ogilvy
"spences10" wrote in message
ups.com...
Hi,

I have devised a UserForm that asks for a username and password which
in turn unlocks certain parts of a work book for that user, I want to
enable them to change the password that has been assigned to them.

I am currently trying to use InputBox method for this, with some degree
of success where I can populate the sheet with the passwords on it, but
not for each individual user. So what I think I need is a way to look
up who the user is in the array then change the password for that user.





All times are GMT +1. The time now is 06:50 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com