Dag Lisa,
Probeer deze code eens. Ik neem aan dat je voldoende ervaring met VBA hebt om de verschillen te zien/interpreteren. Mocht je evenwel nog vragen, shoot. (Best de code opkuisen indien het werkt.)
Private Sub Workbook_Open()
ShowSheet
End Sub
Sub ShowSheet()
Dim ws As Worksheet
Dim wsAllowed As Worksheet
'If SuperUser, show all:
If Application.Username = "Lisa Is" Or Application.Username = "Bart A" Then 'insert Super User's name here
For Each ws In Worksheets
ws.Visible = xlSheetVisible
Next
Exit Sub
End If
'If not a super user, only show the associated sheet
Set wsAllowed = GetAllowedSheet(Application.Username)
If Not wsAllowed Is Nothing Then
wsAllowed.Visible = xlSheetVisible 'make sure the sheet is visible before hiding the others
Else
''' wat moet gebeuren indien geen gekende user???
End If
'Hide all sheets that user isn't permitted to see.
For Each ws In Worksheets
If ws.Name <> wsAllowed.Name Then ws.Visible = xlSheetHidden
Next
End Sub
Function GetAllowedSheet(Username) As Worksheet
'Set the sheet each user is allowed to use here.
'adapt the case statements for correct users and correct sheets to display
Select Case Username
Case "Ann L"
Set GetAllowedSheet = Sheets("Ann")
'Case Else
'If code gets here then User Name is unhandled.
'Select Case Application.UserName
Case "Chris L"
Set GetAllowedSheet = Sheets("Chris")
Case Else
'If code gets here then User Name is unhandled.
'Select Case Application.UserName
' Case "Bart A"
' Set GetAllowedSheet = Sheets("Ann")
' Set GetAllowedSheet = Sheets("Chris")
' Set GetAllowedSheet = Sheets("Globaal")
' Set GetAllowedSheet = Sheets("Producten")
' Case Else
'If code gets here then User Name is unhandled.
End Select
End Function