Dim P As Range, lig& 'mémorose les variables
Private Sub Combobox1_Change()
TextBox2 = ""
lig = ComboBox1.ListIndex + 1
If ComboBox1 = "" Then Exit Sub
If lig = 0 Then ComboBox1 = "": Exit Sub
TextBox2 = P.Cells(lig, 2)
End Sub
Private Sub CommandButton1_Click()
Dim c As Range, v#
Combobox1_Change
If lig = 0 Then Exit Sub
If TextBox1 = "" Then TextBox1.SetFocus: Exit Sub
Set c = P.Rows(lig).Find("", P.Cells(lig, 2), xlValues)
v = Val(Replace(TextBox1, ",", "."))
If v > 0 Then c = v
Application.Goto c
End Sub
Private Sub UserForm_Initialize()
Dim h&
With Sheets("VAR_PRIX")
With .Rows("5:" & .Cells.SpecialCells(xlCellTypeLastCell).Row)
If .Row < 5 Then Exit Sub
.Sort .Columns(1), xlAscending, Header:=xlNo 'tri alphabétique
h = Application.CountA(.Columns(1))
If h Then Set P = .Resize(h) Else Exit Sub
End With
ComboBox1.List = P.Columns(1).Resize(, 2).Value 'au moins 2 éléments
End With
End Sub