Private Sub Workbook_Open()
Dim TabGestion() As Variant
With Sheets("Gestion")
NonAutorisé = True
TabGestion = .Range("A2").CurrentRegion.Value 'on récupère les droits d'accès
For i = LBound(TabGestion, 1) + 1 To UBound(TabGestion, 1) 'sur chaque ligne d'id / +1 pour commencer à la ligne 2
If UCase(Environ("username")) = UCase(TabGestion(i, 2)) Then 'si on est sur le bon ID présent en colonne B (2)
NonAutorisé = False
For j = LBound(TabGestion, 2) + 2 To UBound(TabGestion, 2) 'on parcourt les colonnes = les feuilles / +2 pour commencer à la colonne C (3)
Sheets(TabGestion(1, j)).Visible = (UCase(TabGestion(i, j)) = "X") ' la feuille est affichée ou pas selon le résultat de la ligne
Next j
End If
Next i
End With
If NonAutorisé Then
MsgBox ("Vous n'avez aucune autorisation, veuillez contacter votre administrateur")
ActiveWorkbook.Close (True)
End If
End Sub