Re : complément de code
Bonjour,
Voici du code à ajouter
1) Impérativement en tête de votre code la portion suivante
(si Option Explicit est spécifiée alors placez-le juste après)
'######## Modifs PMO #######
Dim var
'###########################
2) A la fin de votre code (ou ailleurs)
'############# Modifs PMO #######
Private Sub UserForm_Initialize()
Dim S As Worksheet
Set S = Sheets("Feuil2")
var = S.UsedRange
ComboBox1.RowSource = S.Name & "!" & S.Range(S.Cells(2, 4), _
S.Cells(UBound(var, 1), 4)).Address
ComboBox2.RowSource = S.Name & "!" & S.Range(S.Cells(2, 7), _
S.Cells(UBound(var, 1), 7)).Address
End Sub
Private Sub ComboBox1_AfterUpdate()
Dim i&
txtCommercial.Text = ""
For i& = 2 To UBound(var, 1)
If var(i&, 4) = ComboBox1.Value Then
txtCommercial.Text = var(i&, 5)
Exit For
End If
Next i&
End Sub
Private Sub ComboBox2_AfterUpdate()
Dim i&
txtEmballage.Text = ""
For i& = 2 To UBound(var, 1)
If var(i&, 7) = ComboBox2.Value Then
txtEmballage.Text = var(i&, 8)
Exit For
End If
Next i&
End Sub
'#############################
Cordialement.
PMO
Patrick Morange