nrdz83
XLDnaute Impliqué
Bonjour à tous , à l'ouverture de mon classeur excel j'ai un userform qui me demande la saisi de mon mote de passe d'aprés le code plus bas.
Je voudrais qu'ensuite j'ouvre la feuille "feuil2", quel code je dois rajouter à mon code existant?
D'avance merci à tous , mes amitiés 😎
Private Sub Cmd_Ok_Btn_Click()
Dim RechercheUser As Range
Dim Niveau As Byte
Static TentativePW As Byte, TentativeID As Byte
Me.Caption = T
If Txb_ID_Util = Empty Then End
With Niv5_ADMIN
Set PlageUsers = .Range(.Range("a2"), .Range("A500").End(xlUp))
End With
Set RechercheUser = PlageUsers.Find(Txb_ID_Util, LookIn:=xlValues, lookat:=xlWhole)
If Not RechercheUser Is Nothing Then
If Txb_Pwd_Util = RechercheUser.Offset(0, 1) Then
Niveau = RechercheUser.Offset(0, 2)
GrantingAccess Niveau 'ici passage de paramètres "Niveau"
Else
TentativePW = TentativePW + 1
If TentativePW > 3 Then ThisWorkbook.Close 0
MsgBox "Mot de passe invalide, Tentative N° " & TentativePW & " Sur 3", vbCritical, T
With Me.Txb_Pwd_Util
.Value = ""
.SetFocus
End With
End If
Else
TentativeID = TentativeID + 1
If TentativeID > 3 Then ThisWorkbook.Close 0
MsgBox "Utilisateur inconnu, , Tentative N° " & TentativeID & " Sur 3", vbCritical, T
With Me.Txb_ID_Util
.SetFocus
.SelStart = 0
.SelLength = Len(Me.Txb_ID_Util.Text)
End With
End If
End Sub
Je voudrais qu'ensuite j'ouvre la feuille "feuil2", quel code je dois rajouter à mon code existant?
D'avance merci à tous , mes amitiés 😎
Private Sub Cmd_Ok_Btn_Click()
Dim RechercheUser As Range
Dim Niveau As Byte
Static TentativePW As Byte, TentativeID As Byte
Me.Caption = T
If Txb_ID_Util = Empty Then End
With Niv5_ADMIN
Set PlageUsers = .Range(.Range("a2"), .Range("A500").End(xlUp))
End With
Set RechercheUser = PlageUsers.Find(Txb_ID_Util, LookIn:=xlValues, lookat:=xlWhole)
If Not RechercheUser Is Nothing Then
If Txb_Pwd_Util = RechercheUser.Offset(0, 1) Then
Niveau = RechercheUser.Offset(0, 2)
GrantingAccess Niveau 'ici passage de paramètres "Niveau"
Else
TentativePW = TentativePW + 1
If TentativePW > 3 Then ThisWorkbook.Close 0
MsgBox "Mot de passe invalide, Tentative N° " & TentativePW & " Sur 3", vbCritical, T
With Me.Txb_Pwd_Util
.Value = ""
.SetFocus
End With
End If
Else
TentativeID = TentativeID + 1
If TentativeID > 3 Then ThisWorkbook.Close 0
MsgBox "Utilisateur inconnu, , Tentative N° " & TentativeID & " Sur 3", vbCritical, T
With Me.Txb_ID_Util
.SetFocus
.SelStart = 0
.SelLength = Len(Me.Txb_ID_Util.Text)
End With
End If
End Sub