code for password required
Code:
Private Sub Cancel_Click()
'Sheets("Protected").Visible = xlVeryHidden
MsgBox "Password Not Entered. Workbook will close!"
Unload Me
ThisWorkbook.Close
End Sub
Private Sub EnterPassword_Click()
Dim password As String
password = PasswordInput.Text
If password = WorksheetFunction.VLookup(UserList.Value, Range("Users_List"), 2, 0) Then
'Sheets("Protected").Visible = xlVeryHidden
'Sheets("Blank").Visible = xlVeryHidden
MsgBox "Password Accepted"
Unload Me
Else
'Sheets("Protected").Visible = xlVeryHidden
'Sheets("Blank").Visible = xlVeryHidden
MsgBox "Password Not Accepted, Workbook will close"
Unload Me
ThisWorkbook.Close
End If
End Sub
Private Sub UpdatePassword_Click()
Dim password As String
password = PasswordInput.Text
If password = WorksheetFunction.VLookup(UserList.Value, Range("Users_List"), 2, 0) Then
User = UserList.Value
Sheets("Blank").Range("A1").Value = User
Unload Me
UserForm2.Show
Else
MsgBox "Passwords do not match, please try again"
End If
End Sub
Private Sub UserForm_Terminate()
Dim password As String
password = PasswordInput.Text
If PasswordInput.Text = "" Or UserList.Value = "" Then
MsgBox "must use this form, workbook will close"
ThisWorkbook.Close
ElseIf password = WorksheetFunction.VLookup(UserList.Value, Range("Users_List"), 2, 0) Then
End If
End Sub
Private Sub UserList_Change()
End Sub
code for new password
Code:
Private Sub CommandButton1_Click()
Dim password As String
password = TextBox1.Text
secondpassword = TextBox2.Text
If password = secondpassword Then
With Worksheets("Protected").Range("Users")
Set c = .Find(Sheets("Blank").Range("A1").Value, LookIn:=xlValues)
If Not c Is Nothing Then
Sheets("Protected").Range(c.Address).Offset(0, 1).Value = password
Sheets("Protected").Visible = xlVeryHidden
Sheets("Blank").Visible = xlVeryHidden
MsgBox "Password Updated"
Unload Me
Sheets("Blank").Range("A1").Value = ""
End If
End With
Else
MsgBox "Passwords do not match, please try again"
End If
End Sub
Private Sub TextBox1_Change()
End Sub
Private Sub TextBox2_Change()
End Sub
Private Sub UserForm_Terminate()
Dim User As String
User = Sheets("Blank").Range("A1").Value
If TextBox1.Value = WorksheetFunction.VLookup(User, Range("Users_List"), 2, 0) Then
Else
MsgBox "must use this form, workbook will close"
ThisWorkbook.Close
End If
End Sub
this code, I've put at this workbook.
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Sheets("Blank").Visible = xlSheetVisible
End Sub
Private Sub Workbook_Open()
If Sheets("Blank").Visible <> xlSheetVisible Then
Sheets("Blank").Visible = xlSheetVisible
End If
Sheets("Blank").Select
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Sheets("Protected").Visible = xlSheetVisible
UserForm1.Show
End Sub
the highlighted code that occur an error serving
debug is...
If TextBox1.Value = WorksheetFunction.VLookup(User, Range("Users_List"), 2, 0) Then
thank you..
Bookmarks