tu pourras aussi changer ton code comme ci-dessous :
il y a longtemps que je n'avais pas vu ton fichier et beaucoup d'améliorations sont encore à faireCode:
1
2
3
4
5
6
7
8
9
10
11
12
13
14 Private Sub immat_Click() Dim ch As Range, Der_ligne As Integer With Sheets("base") If modele.ListIndex = -1 Then: MsgBox "Chosir d'abord un modele": modele.SetFocus: Exit Sub Der_ligne = .Range("A" & .Rows.Count).End(xlUp).Row If dte_sortie = True Then Set ch = .Range("a2:h" & Der_ligne).Columns(3).Find(immat) If Not ch Is Nothing Then chassis = ch.Offset(0, 1): agent_p = ch.Offset(0, 2) End If End If End With chassis.SetFocus End Sub
je viens de voir un autre problème, change ton code du bouton "valider" comme ci-dessous :
Bonne journéeCode:
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 Private Sub valid_Click() Dim Der_ligne As Integer, ch As Range With Sheets("base") Der_ligne = .Range("A" & .Rows.Count).End(xlUp).Row + 1 If dte_sortie = True Then Set ch = .Range("C1:C" & Der_ligne - 1).Find(immat) ch.Offset(0, 4) = CDate(mouvement) TRI End If If dte_entree = True Then .Cells(Der_ligne, 1) = marque .Cells(Der_ligne, 2) = modele .Cells(Der_ligne, 3) = immat .Cells(Der_ligne, 4) = chassis .Cells(Der_ligne, 5) = agent_p .Cells(Der_ligne, 6) = CDate(mouvement) TRI End If If dte_vo = True Then .Cells(Der_ligne, 7) = CDate(mouvement) End If End With End Sub