LostInTheTrees
New Member
- Joined
- Jul 23, 2014
- Messages
- 5
Hi!
I'm using Excel 2010 (Windows 7) to develop a workbook with the goal of tying conditionally visible worksheets to a case statement. Conceptually, I want a user to enter a password and click on the enter password button, and have the sheets they are authorized to see appear in the tabs below. This is not meant as a super secure file, and I recognize that Excel VBA is not the most secure option.
Currently, when the "submit password" button is clicked, the entered value ("password") is moved onto the workcenter sheet. That cell on the workcenter is named "pswd." The cell below utilizes the value of pswd to perform a VLOOKUP to determine the Case tied to the password. My macros have been compiling, but not actually altering the visibility of the sheets as anticipated.
P.S. My original idea included an IFERROR(VLOOKUP()) combination, which would yield a failed Case Q if the VLOOKUP failed. This is NOT necessary, just an idea I have been playing around with.
If this is unclear, I will gladly try to clarify. If this is impossible, that would be incredibly disappointing. Also, if it's going to be a lot of work, please do not feel like you have to do it for me. I just need some help being pointed in the right direction.
No matter what, thanks for your time/help.
Sincerely,
LostInTheTrees
I'm using Excel 2010 (Windows 7) to develop a workbook with the goal of tying conditionally visible worksheets to a case statement. Conceptually, I want a user to enter a password and click on the enter password button, and have the sheets they are authorized to see appear in the tabs below. This is not meant as a super secure file, and I recognize that Excel VBA is not the most secure option.
Currently, when the "submit password" button is clicked, the entered value ("password") is moved onto the workcenter sheet. That cell on the workcenter is named "pswd." The cell below utilizes the value of pswd to perform a VLOOKUP to determine the Case tied to the password. My macros have been compiling, but not actually altering the visibility of the sheets as anticipated.
P.S. My original idea included an IFERROR(VLOOKUP()) combination, which would yield a failed Case Q if the VLOOKUP failed. This is NOT necessary, just an idea I have been playing around with.
Code:
Private Sub gatekeeper() Dim attempted As String
attempted = Range("enterpassword").Value
Range("enterpassword").Value = ""
Range("pswd").Value = attempted
attempted = ""
casebuilder
End Sub
Private Sub casebuilder()
Dim errq As String
Dim casevalue As String
Dim dwsp As String
dwsp = Range("pswd").Value
cased = Application.WorksheetFunction.VLookup(dwsp, Sheet88.Range("L11:N25"), 3, False)
casevalue = cased
Select Case casevalue
Case A
Sheet11.Visible = xlSheetVisible
Sheet13.Visible = xlSheetVisible
Sheet41.Visible = xlSheetVisible
Sheet43.Visible = xlSheetVisible
Case B
Sheet11.Visible = xlSheetVisible
Sheet12.Visible = xlSheetVisible
Sheet13.Visible = xlSheetVisible
Sheet41.Visible = xlSheetVisible
Sheet42.Visible = xlSheetVisible
Sheet43.Visible = xlSheetVisible
Case C
Sheet21.Visible = xlSheetVisible
Sheet23.Visible = xlSheetVisible
Sheet24.Visible = xlSheetVisible
Sheet26.Visible = xlSheetVisible
Case Q
errq = errq + 1
Range("reporterror").Value = errq
If errq = 3 Then Unload Workbook
End Select
End Sub
If this is unclear, I will gladly try to clarify. If this is impossible, that would be incredibly disappointing. Also, if it's going to be a lot of work, please do not feel like you have to do it for me. I just need some help being pointed in the right direction.
No matter what, thanks for your time/help.
Sincerely,
LostInTheTrees