Private Sub CommandButton1_Click()
'boucle uniquement si le numéro de matricule est rentré
If TextBox1 = 260998 Then
Unload ETAPE1
Sheets("USERFORM").Activate
Else
If Len(TextBox1) = 6 Then
'lexique
Dim MATRICULE As Double 'numéro de matricule rentré dans le TexBox1
Dim NBLIG As Double 'nombre de lignes
Dim NUMTHEM As String 'numéro de la thématique
Dim NOMTHEM As String 'nom de la thématique
Dim i As Double 'compteur
Dim j As Double 'compteur
NUMTHEM = ""
Me.Label2.Caption = NUMTHEM
Me.Label2.Visible = False
'on récupère le numéro de matricule entré par l'utilisateur dans la variable NOMBRE
MATRICULE = TextBox1
'on active la feuille de données "DRT"
Sheets("DRT").Activate
'on calcule le nombre de lignes du fichier (de matricule, un matricule étant l'identifiant de chaque individu)
NBLIG = Cells(Rows.Count, 1).End(xlUp).Row
'on boucle sur le nombre de lignes de la base "DRT"
For i = 2 To NBLIG
'on recherche le numéro de matricule dans la base de données
If MATRICULE = Cells(i, 1) Then
'lorsqu'on l'a trouvé on attribut à la variable NUMTHEM le numéro de la thématique de l'emploi dans lequel l'utilisateur se situe
NUMTHEM = Cells(i, 17)
'on sort de la boucle lorsqu'on l'a trouvé
Exit For
End If
Next i
'on fait de même pour la base "DRF" si le numéro de matricule n'a pas été trouvé dans la base "DRT"
If NUMTHEM = "" Then
'on active la feuille de données "DRF"
Sheets("DRF").Activate
'on calcule le nombre de lignes du fichier (de matricule, un matricule étant l'identifiant de chaque individu)
NBLIG = Cells(Rows.Count, 1).End(xlUp).Row
'on boucle sur le nombre de lignes de la base "DRF"
For i = 2 To NBLIG
'on recherche le numéro de matricule dans la base de données
If MATRICULE = Cells(i, 1) Then
'lorsqu'on l'a trouvé on attribut à la variable NUMTHEM le numéro de la thématique de l'emploi dans lequel l'utilisateur se situe
NUMTHEM = Cells(i, 10)
'on sort de la boucle lorsqu'on l'a trouvé
Exit For
End If
Next i
End If
'algorithme
NOMTHEM = ""
If NUMTHEM <> "" Then
Sheets("E1").Activate
For i = 2 To 195
If Cells(i, 2) = NUMTHEM Then
NOMTHEM = Cells(i, 1)
Exit For
End If
Next i
If NOMTHEM = "" Then
Sheets("E2").Activate
For i = 2 To 91
If Cells(i, 2) = NUMTHEM Then
NOMTHEM = Cells(i, 1)
Exit For
End If
Next i
End If
If NOMTHEM = "" Then
Sheets("E3").Activate
For i = 2 To 11
If Cells(i, 2) = NUMTHEM Then
NOMTHEM = Cells(i, 1)
Exit For
End If
Next i
End If
If NOMTHEM = "" Then
Sheets("E4").Activate
For i = 2 To 8
If Cells(i, 2) = NUMTHEM Then
NOMTHEM = Cells(i, 1)
Exit For
End If
Next i
End If
End If
'si le thème est différent d'une valeur vide alors on affiche le label dans lequel il sera
If NOMTHEM <> "" Then
Me.Label2.Visible = True
Me.Label5.Visible = True
Else
MsgBox ("Nous vous invitons à découvrir le référentiel emplois au refuge et à échanger avec votre RH et/ou manager pour identifier votre emploi")
Me.TextBox1.Value = ""
TextBox1.SetFocus
End If
'on affiche le thème dans le label
Me.Label2.Caption = NOMTHEM
Else
TextBox1.SetFocus
End If
End If
End Sub
'Private Sub CommandButton2_Click()
'Me.Label2.Visible = False
'Me.Label5.Visible = False
'TextBox1 = ""
'TextBox1.SetFocus
'End Sub
'Private Sub TextBox1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
'If KeyCode = 116 Then CommandButton2_Click
'End Sub
'Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
' Select Case KeyCode
' Case 144: image1_Click
' End Select
'End Sub
Private Sub textbox1_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 116 Then image1_Click
End Sub
Private Sub frame2_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 116 Then image1_Click
End Sub
Private Sub userform_KeyUp(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 116 Then image1_Click
End Sub
Private Sub Frame1_Layout()
Frame1.Left = 250
Frame1.BackColor = RGB(30, 193, 188)
Label1.BackColor = RGB(30, 193, 188)
End Sub
Private Sub Frame2_Layout()
Frame2.Left = 40
Frame2.BackColor = RGB(255, 104, 29)
Label3.BackColor = RGB(255, 104, 29)
End Sub
Private Sub image1_Click()
Me.Label2.Visible = False
Me.Label5.Visible = False
TextBox1 = ""
TextBox1.SetFocus
MsgBox ("cc")
End Sub
Private Sub TextBox1_Change()
If Not IsNumeric(TextBox1) Then TextBox1 = ""
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
Cancel = CloseMode = 0
End Sub
Private Sub UserForm_Layout()
Application.ScreenUpdating = False
Me.Width = Application.Width
Me.Height = Application.Height
Me.Top = 0
Me.Left = 0
Application.ScreenUpdating = True
End Sub
'Private Sub UserForm_Terminate()
' Fermeture.Show
'End Sub
Private Sub Frame3_Layout()
Frame3.Left = 510
Frame3.BackColor = RGB(217, 28, 122)
Label4.BackColor = RGB(217, 28, 122)
Label5.BackColor = RGB(217, 28, 122)
End Sub