ndfightingirish1971
New Member
- Joined
- May 14, 2013
- Messages
- 6
I am working on a data collection sheet that is going to be used by the operators on the shop floor. I need to limit the access for changing tolerances, manually changing data, modifying formulas, etc. I have a "USER" button and "ADMINISTRATOR" button that are linked to macros. The macros work in locking everything that needs to be locked for the users and unlocking everything when the administrator needs to add or modify features, however, the password I set does not function properly. It does not matter what you put into the userform. Once you click OK, it unlocks. I am completely new to writing code in userforms, so I would greatly appreciate some assistance. Thanks in advance!
Userform code:
Private Sub PASSWORD_CLICK()
If Me.Password.Value = "password" Then
LoginFlag = True
Me.Hide
Unload Me
Exit Sub
End If
End If
MsgBox "INCORRECT PASSWORD!"
End Sub
Private Sub CommandButton1_Click()
Hide
Unload Me
End Sub
Private Sub CommandButton2_Click()
Unload Me
End Sub
Private Sub TextBox1_Change()
End Sub
______________________________________________________________________________________________
Administrator code:
Sub ADMIN()
Password.Show
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
If ws.Name <> "MAIN MENU" Then ws.Visible = xlSheetVisible
Next
For Each Sheet In Sheets
Sheet.Activate
ActiveWindow.DisplayGridlines = True
ActiveWindow.DisplayHeadings = True
Next Sheet
Sheets("MAIN MENU").Select
ActiveSheet.Unprotect Password:="password"
Sheets("LOG SHEET").Select
ActiveSheet.Unprotect Password:="password"
Sheets("PARAMETERS SHEET").Select
ActiveSheet.Unprotect Password:="password"
Sheets("PART MEASUREMENT").Select
ActiveSheet.Unprotect Password:="password"
Sheets("CAPABILITY SHEET").Select
ActiveSheet.Unprotect Password:="password"
Sheets("DATA STORAGE").Select
ActiveSheet.Unprotect Password:="password"
Sheets("MAIN MENU").Select
End Sub
Userform code:
Private Sub PASSWORD_CLICK()
If Me.Password.Value = "password" Then
LoginFlag = True
Me.Hide
Unload Me
Exit Sub
End If
End If
MsgBox "INCORRECT PASSWORD!"
End Sub
Private Sub CommandButton1_Click()
Hide
Unload Me
End Sub
Private Sub CommandButton2_Click()
Unload Me
End Sub
Private Sub TextBox1_Change()
End Sub
______________________________________________________________________________________________
Administrator code:
Sub ADMIN()
Password.Show
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
If ws.Name <> "MAIN MENU" Then ws.Visible = xlSheetVisible
Next
For Each Sheet In Sheets
Sheet.Activate
ActiveWindow.DisplayGridlines = True
ActiveWindow.DisplayHeadings = True
Next Sheet
Sheets("MAIN MENU").Select
ActiveSheet.Unprotect Password:="password"
Sheets("LOG SHEET").Select
ActiveSheet.Unprotect Password:="password"
Sheets("PARAMETERS SHEET").Select
ActiveSheet.Unprotect Password:="password"
Sheets("PART MEASUREMENT").Select
ActiveSheet.Unprotect Password:="password"
Sheets("CAPABILITY SHEET").Select
ActiveSheet.Unprotect Password:="password"
Sheets("DATA STORAGE").Select
ActiveSheet.Unprotect Password:="password"
Sheets("MAIN MENU").Select
End Sub