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 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
| Private Sub ComboBox7_Change()
Dim onglet As Worksheet
Dim derniere_ligne As Long
Dim reference As String
Set onglet = Worksheets("RJ")
derniere_ligne = onglet.Cells(Rows.Count, 1).End(xlUp).Row
If ComboBox7.Value = "" Then
Unload UserForm1
UserForm1.Show
Else
reference = ComboBox7.Value
For i = 2 To derniere_ligne
If onglet.Cells(i, 8) = reference Then
'Cells(derniere_ligne + 1, 2) =
ComboBox1.Value = onglet.Cells(i, 2)
ComboBox2.Value = onglet.Cells(i, 3)
TextBox1.Value = onglet.Cells(i, 4)
TextBox11.Value = onglet.Cells(i, 5)
Nom.Value = onglet.Cells(i, 6)
Prenom.Value = onglet.Cells(i, 7)
'Concatenate pour recherche
TextBox2.Value = onglet.Cells(i, 9)
TextBox3.Value = onglet.Cells(i, 10)
TextBox4.Value = onglet.Cells(i, 11)
ComboBox3.Value = onglet.Cells(i, 12)
TextBox5.Value = onglet.Cells(i, 13)
ComboBox4.Value = onglet.Cells(i, 14)
TextBox7.Value = onglet.Cells(i, 15)
'calcul date surveillance
TextBox12.Value = onglet.Cells(i, 17)
ComboBox5.Value = onglet.Cells(i, 18)
ComboBox6.Value = onglet.Cells(i, 19)
TextBox6.Value = onglet.Cells(i, 20)
End If
Next
End If
End Sub
Private Sub userform_initialize()
Dim onglet As Worksheet
Dim derniere_ligne As Long
Dim arr_data As Variant
Set onglet = Worksheets("RJ")
derniere_ligne = onglet.Cells(Rows.Count, 1).End(xlUp).Row
If derniere_ligne > 1 Then
arr_data = onglet.Range(onglet.Cells(2, 8), onglet.Cells(derniere_ligne, 8))
'With Me.ComboBox7
'.ColumnCount = 8
'.ColumnWidths = "30;0;0;0;0;0;0;75"
'End With
ComboBox7.List = arr_data
End If
'With Sheets("RJ")
'Dim i As Integer
'i = 2
'Do While Worksheets("RJ").Cells(i, 1) <> 0
'ComboBox7.AddItem Sheets("RJ").Cells(i, 8)
'i = i + 1
'Loop
'ComboBox7.ListIndex = 0
'End With
With ComboBox1
.AddItem ""
.AddItem "Client Suivi LCBFT"
.AddItem "Réquisition Judicaire"
End With
With ComboBox2
.AddItem ""
.AddItem "Enquête Préliminaire"
.AddItem "Client Suivi"
End With
With ComboBox3
.AddItem ""
.AddItem "Abeille Vie"
.AddItem "Abeille Retraite Professionnelle"
.AddItem "Abeille Epargne Retraite"
.AddItem "ALPIDAC"
End With
With ComboBox4
.AddItem ""
.AddItem "Oui"
.AddItem "Non"
End With
With ComboBox5
.AddItem ""
.AddItem "Oui"
.AddItem "Non"
End With
With ComboBox6
.AddItem ""
.AddItem "Anthony GIOVANNOLI"
.AddItem "Mona FOUDA"
.AddItem "Sarah TIDJANI"
.AddItem "Stéphane SEBELOUE"
End With
TextBox1.Value = DateValue(Format(Date, "dd/mm/yyyy"))
End Sub
Private Sub Quitter_Click()
Unload Me
End Sub
Private Sub Ajouter_Click()
'Bouton Ajouter
Dim onglet As Worksheet
Dim derniere_ligne As Long
Dim reference As String
Dim modification As Boolean
If ComboBox7.Value = "" Then
modification = False
Else
modification = True
End If
Set onglet = Worksheets("RJ")
derniere_ligne = onglet.Cells(Rows.Count, 1).End(xlUp).Row
If modification = False Then
If derniere_ligne = 1 Then
reference = 1
Else
reference = onglet.Cells(derniere_ligne, 1) + 1
End If
With onglet
Cells(derniere_ligne + 1, 1) = reference
Cells(derniere_ligne + 1, 2) = ComboBox1.Value
Cells(derniere_ligne + 1, 3) = ComboBox2.Value
Cells(derniere_ligne + 1, 4) = DateValue(Format(Date, "dd/mm/yyyy"))
If TextBox11.Value <> "" Then
Cells(derniere_ligne + 1, 5) = CDate(TextBox11.Value)
End If
Cells(derniere_ligne + 1, 6) = Nom.Value
Cells(derniere_ligne + 1, 7) = Prenom.Value
'Concatenate pour recherche
If TextBox2.Value <> "" Then
Cells(derniere_ligne + 1, 9) = CDate(TextBox2.Value)
End If
Cells(derniere_ligne + 1, 10) = TextBox3.Value
Cells(derniere_ligne + 1, 11) = TextBox4.Value
Cells(derniere_ligne + 1, 12) = ComboBox3.Value
Cells(derniere_ligne + 1, 13) = TextBox5.Value
Cells(derniere_ligne + 1, 14) = ComboBox4.Value
If TextBox7.Value <> "" Then
Cells(derniere_ligne + 1, 15) = CDate(TextBox7.Value)
End If
'calcul date surveillance
If TextBox12.Value <> "" Then
Cells(derniere_ligne + 1, 17) = CDate(TextBox12.Value)
End If
Cells(derniere_ligne + 1, 18) = ComboBox5.Value
Cells(derniere_ligne + 1, 19) = ComboBox6.Value
Cells(derniere_ligne + 1, 20) = TextBox6.Value
End With
Else
reference = ComboBox7.Value
For i = 2 To derniere_ligne
If onglet.Cells(i, 8) = reference Then
'Cells(derniere_ligne + 1, 2) =
onglet.Cells(i, 2) = ComboBox1.Value
onglet.Cells(i, 3) = ComboBox2.Value
onglet.Cells(i, 4) = DateValue(Format(Date, "dd/mm/yyyy"))
If TextBox11.Value <> "" Then
onglet.Cells(i, 5) = CDate(TextBox11.Value)
Else: onglet.Cells(i, 5) = ""
End If
onglet.Cells(i, 6) = Nom.Value
onglet.Cells(i, 7) = Prenom.Value
'Concatenate pour recherche
If TextBox2.Value <> "" Then
onglet.Cells(i, 9) = CDate(TextBox2.Value)
Else: onglet.Cells(i, 9) = ""
End If
onglet.Cells(i, 10) = TextBox3.Value
onglet.Cells(i, 11) = TextBox4.Value
onglet.Cells(i, 12) = ComboBox3.Value
onglet.Cells(i, 13) = TextBox5.Value
onglet.Cells(i, 14) = ComboBox4.Value
If TextBox7.Value <> "" Then
onglet.Cells(i, 15) = CDate(TextBox7.Value)
Else: onglet.Cells(i, 15) = ""
End If
'calcul date surveillance
If TextBox12.Value <> "" Then
onglet.Cells(i, 17) = CDate(TextBox12.Value)
Else: onglet.Cells(i, 17) = ""
End If
onglet.Cells(i, 18) = ComboBox5.Value
onglet.Cells(i, 19) = ComboBox6.Value
onglet.Cells(i, 20) = TextBox6.Value
End If
Next
End If
Unload UserForm1
UserForm1.Show
End Sub |
Partager