Private Sub UserForm_Initialize()
Set fent = Sheets("Fiche des entrées")
Set fs = Sheets("Fiche des sorties"), ensuite pour la recherche.
' A ADAPTER
With fent
For i = 2 To .Range("b65536").End(xlUp).Row
ComboBox1 = .Range("b" & i)
If ComboBox1.ListIndex = -1 Then ComboBox1.AddItem .Range("b" & i)
Next i
For i = 2 To .Range("d65536").End(xlUp).Row
ComboBox2 = .Range("d" & i)
If ComboBox2.ListIndex = -1 Then ComboBox2.AddItem .Range("d" & i)
Next i
For i = 2 To .Range("g65536").End(xlUp).Row
ComboBox3 = .Range("g" & i)
If ComboBox3.ListIndex = -1 Then ComboBox3.AddItem .Range("g" & i)
Next i
End With
End Sub
Private Sub Rechercher()
With fent
Set plage = .Range("b2:j" & Rows.Count).End(xlUp).Row
Set cel = plage.Find(ComboBox2, , xlValues, xlWhole)
If Not cel Is Nothing Then
ComboBox3 = cel.offset(0, 4)
ComboBox1 = cel.offset(0, 6)
TextBox8 = cel.offset(0, 2)
etc.
End If
End With
Private Sub ComboBox2_Change()
Call Rechercher
End Sub
Private Sub CommandButton1_Click()
With Fs
lig = .Range("a" & Rows.Count).End(xlup).Row + 1
.Range("f" & lig) = TextBox8
End With
End Sub
Private Sub TextBox4_AfterUpdate()
TextBox8 = TextBox8 - TextBox4
End Sub