1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
| Option Explicit
Dim Ws As Worksheet
Private Sub TextBox6_Change()
End Sub
'Pour le formulaire
Private Sub UserForm_Initialize()
'Pour la date de la feuille de soin
TextBox1 = Date
'Code Combobox1 Patient
Dim J As Long
Dim I As Integer
ComboBox1.ColumnCount = 1 'Pour la liste déroulante Nom & Prénom du Patient
ComboBox1.List() = Array()
Set Ws = Sheets("Patients") 'Correspond au nom de votre onglet dans le fichier Excel
With Me.ComboBox1
For J = 2 To Ws.Range("A" & Rows.Count).End(xlUp).Row
.AddItem Ws.Range("A" & J)
Next J
End With
For I = 1 To 6
Me.Controls("TextBox" & I).Visible = True
Next I
'Code Combobox1 Remplaçante
Dim L As Long
Dim K As Integer
ComboBox2.ColumnCount = 1 'Pour la liste déroulante Nom & Prénom de la remplaçante
ComboBox2.List() = Array()
Set Ws = Sheets("Remplaçante") 'Correspond au nom de votre onglet dans le fichier Excel
With Me.ComboBox2
For L = 2 To Ws.Range("A" & Rows.Count).End(xlUp).Row
.AddItem Ws.Range("A" & L)
Next L
End With
For K = 7 To 7
Me.Controls("TextBox" & I).Visible = True
Next K
End Sub
'Pour les Données Patients
Private Sub ComboBox1_Change()
Dim Ligne As Long
Dim I As Integer
If Me.ComboBox1.ListIndex = -1 Then Exit Sub
Ligne = Me.ComboBox1.ListIndex + 2
TextBox2 = Ws.Cells(Ligne, "B")
For I = 2 To 6
Me.Controls("TextBox" & I) = Ws.Cells(Ligne, I)
Next I
End Sub
'Pour les Données Remplaçante
Private Sub ComboBox2_Change()
Dim Ligne As Long
Dim K As Integer
If Me.ComboBox2.ListIndex = -1 Then Exit Sub
Ligne = Me.ComboBox2.ListIndex + 2
TextBox7 = Ws.Cells(Ligne, "B")
For K = 7 To 7
Me.Controls("TextBox" & K) = Ws.Cells(Ligne, K)
Next K
End Sub |
Partager