I've seen numerous posts on this topic and have tried to adapt each of them to suit my needs, but I'm still running into errors in my code. What I'm trying to accomplish is to have certain worksheets in my workbook unhide for a specific user. I have a worksheet called "Summary" and then I have 8 additional worksheets...1 for each member of our team. What I'd like to happen is that when a member opens the file, only the Summary sheet and that person's individual sheet are visible (all other sheets are hidden); however, when our manager opens the file, I'd like him to have visibility to all sheets.
Here's what I currently have:
I'm getting a compile error that reads, "Else without If". I've tried a number of variations to address this, but nothing seems to work. Any ideas on what I'm doing wrong? Feels like I'm overlooking something fairly simple.
Thanks in advance for the help!
Here's what I currently have:
Code:
Private Sub Workbook_Open()
Application.ScreenUpdating = False
Dim Sht As Worksheet
If Environ("UserName").Value = "N13802" Then
For Each Sht In ThisWorkbook.Sheets
Sht.Visible = True
Else
If Environ("UserName").Value <> "N13802" Then
For Each Sht In ThisWorkbook.Sheets
If Sht.Name <> "Summary" Then
Sht.Visible = xlSheetHidden
End If
Next
Sheets(Environ("UserName")).Visible = True
Sheets(Environ("UserName")).Activate
ActiveSheet.Range("E4").Select
End If
End Sub
I'm getting a compile error that reads, "Else without If". I've tried a number of variations to address this, but nothing seems to work. Any ideas on what I'm doing wrong? Feels like I'm overlooking something fairly simple.
Thanks in advance for the help!