I am currently having some code issues in regards to my multiple passwords I setup. For some reason the "basic level" or when someone opens the spreadsheet is allowing them to actually edit the ranges of "attendees","traveldates", and "location". These cells are only suppose to become editable after using the password "model" or supermodel". Does anyone know why these cells are currently editable when the the workbook opens instead of once the password is entered?
The first code is run when the commandbutton is pressed and the second code is when the workbook opens. I have included the overall file as well.
If textpassword.Text = "model" Then
MsgBox "Managerial Login Successful"
Sheets("Taxi Fare").Visible = True
Sheet1.Unprotect
Sheet7.Unprotect
Worksheets("Attendees").Range("attendees").Locked = False
Worksheets("Menu Page").Range("traveldates").Locked = False
Worksheets("Menu Page").Range("location").Locked = False
Sheet1.Protect
Sheet7.Protect
Else
If textpassword.Text = "supermodel" Then
MsgBox "Full Access Granted"
Sheet1.Unprotect
i = 1
Do Until i > Sheets.Count
Set ws = Sheets(i)
ws.Visible = xlSheetVisible
i = i + 1
Loop
Sheet1.Unprotect
Sheet7.Unprotect
Sheet3.Unprotect
Sheet5.Unprotect
Sheet9.Unprotect
Sheet17.Unprotect
Sheet13.Unprotect
Sheet18.Unprotect
Unload Me
Unload Me
Else
MsgBox "The passowrd entered is incorrect.", vbCritical, "Incorrect Password"
End If
End If
Unload Me
End Sub
Private Sub Workbook_Open()
For Each ws In ActiveWorkbook.Worksheets
If ws.Name = "Airline Raw Data" _
Or ws.Name = "Hotel Raw Data" _
Or ws.Name = "Transportation Raw" _
Or ws.Name = "Employee Data" _
Or ws.Name = "WeatherDatabase" _
Or ws.Name = "Per Diem" _
Or ws.Name = "Transportation" _
Or ws.Name = "Currency Calculator" _
Or ws.Name = "Update Log" _
Or ws.Name = "Random Inputs" _
Or ws.Name = "Other Cities" _
Or ws.Name = "Taxi Fare" Then
ws.Visible = xlSheetVeryHidden
End If
Next ws
Worksheets("Currency Calculator").Activate
Selection.QueryTable.Refresh BackgroundQuery:=False
Worksheets("Menu Page").Activate
With Sheets("Employee Data")
.Range(("A2"), .Range("A2").End(xlDown)).Name = "Employee_ID"
End With
Sheet1.Protect
Sheet7.Protect
Sheet3.Protect
Sheet5.Protect
Sheet9.Protect
Sheet17.Protect
Sheet13.Protect
Sheet18.Protect
End Sub
Hong Kong 730PM.xlsm
Bookmarks