Bonjour,
Merci pour les précisions.
Dans ce cas dans la feuille login :
Option Explicit
Private Sub CommandButton1_Click()
Dim USER As Object, C%, WS As Worksheet
'Code se déclenchant au clic sur bouton
'Si TextBox1 est vide
If TextBox_utilisateur = "" Then
'Message à l'utilisateur
MsgBox "Saisie du nom d'utilisateur obligatoire.", vbInformation
'sortie de la procédure
Exit Sub
End If
'Même chose avec TextBox2
If TextBox_motpasse = "" Then
MsgBox "Saisie du mot de passe obligatoire.", vbInformation
Exit Sub
End If
'Lance la fonction VerifMDP en utilisant :
'- TextBox1 comme paramètre "utilisateur"
'- TextBox2 comme paramètre "MdP"
Set USER = Worksheets("Utilisateurs").ListObjects("Tableau1").DataBodyRange.Columns(1).Find(TextBox_utilisateur.Text)
If USER.Offset(0, 1).Value = TextBox_motpasse Then
For C = 4 To Worksheets("Utilisateurs").ListObjects("Tableau1").ListColumns.Count
If Worksheets("Utilisateurs").Cells(USER.Row, C) <> "" Then
Worksheets(Worksheets("Utilisateurs").Cells(2, C).Value).Visible = True
Else
Worksheets(Worksheets("Utilisateurs").Cells(2, C).Value).Visible = False
End If
Next C
'Si la fonction renvoie FAUX :
Else
For Each WS In Worksheets
If WS.Name <> "Login" Then WS.Visible = False
Next WS
End If
TextBox_motpasse = ""
TextBox_utilisateur = ""
End Sub
Dans ThisWorkbook
Private Sub Workbook_Open()
Dim WS As Worksheet
For Each WS In Worksheets
If WS.Name <> "Login" Then WS.Visible = False Else WS.Visible = True
Next WS
End Sub
Cf fichier joint pour le remplissage de la matrice des droits d'accès.
Peut être passer le masquage des feuilles en xlVeryHidden sur la propriété Visible.
Ergotamine.