Hi all,
I don't know if this is possible. I would like to run a VBA code but only if the correct password is entered. the below code helps me do this. However, what I'd like to do now is to have it check against a list of usernames and passwords. So bassically when you try and run the code by pressing a command buttion, it will with an input box asking for a username and will ask you to enter a password that is specific to that username based on a list on another worksheet. The username on the other worksheet is in column A and the password in column B. Can anyone amend the below code or come up witha new one.
I hope this makes sense and thanks in advance for your help.
I don't know if this is possible. I would like to run a VBA code but only if the correct password is entered. the below code helps me do this. However, what I'd like to do now is to have it check against a list of usernames and passwords. So bassically when you try and run the code by pressing a command buttion, it will with an input box asking for a username and will ask you to enter a password that is specific to that username based on a list on another worksheet. The username on the other worksheet is in column A and the password in column B. Can anyone amend the below code or come up witha new one.
I hope this makes sense and thanks in advance for your help.
Code:
Private Sub CommandButton2_Click()
Dim Pass As String
Dim Prompt As String
Dim Title As String
Dim UserPass As String
Pass = "MyPassword"
Prompt = "Enter the password to continue"
Title = "Password Input"
UserPass = InputBox(Prompt, Title)
If UserPass <> Pass Then
Prompt = "You have entered an incorrect password"
Title = "Incorrect Passowd"
MsgBox Prompt, vbCritical, Title
Exit Sub
End If
row_number = 0
Do
DoEvents
row_number = row_number + 1
item_in_review = Sheets("Forms Received").Range("A" & row_number)
If item_in_review = Con1.Text Then
Reg2.Text = Sheets("Forms Received").Range("D" & row_number)
Reg3.Text = Sheets("Forms Received").Range("E" & row_number)
Reg125.Text = Sheets("Forms Received").Range("F" & row_number)
Reg4.Text = Sheets("Forms Received").Range("G" & row_number)
Reg5.Text = Sheets("Forms Received").Range("H" & row_number)
Reg6.Text = Sheets("Forms Received").Range("I" & row_number)
Reg7.Text = Sheets("Forms Received").Range("J" & row_number)
Reg8.Text = Sheets("Forms Received").Range("K" & row_number)
Reg9.Text = Sheets("Forms Received").Range("L" & row_number)
End If
Loop Until item_in_review = ""
End Sub