Bon, visiblement, il y a un truc que je n'ai pas dû comprendre sur la façon de joindre un fichier à ma demande. Du coup, je vous mets le script:
Private Sub UserForm_Initialize()
With ListBox1
.ColumnCount = 4
.ColumnWidths = "80;100;50;50"
End With
Me.ListBox1.List = [evts].Value
End Sub
Private Sub TextBox1_Change()
Me.ListBox1.Clear
i = 0
For Each c In Application.Index([evts], , 2)
If UCase(c) Like "*" & UCase(Me.TextBox1) & "*" Then
Me.ListBox1.AddItem
Me.ListBox1.List(i, 0) = c.Offset(0, -1).Value
Me.ListBox1.List(i, 1) = c.Offset(0, 0).Value
Me.ListBox1.List(i, 2) = c.Offset(0, 1).Value
Me.ListBox1.List(i, 3) = c.Offset(0, 2).Value
i = i + 1
End If
Next c
End Sub
Private Sub CommandButton1_Click()
flag = True
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) Then
flag = False
End If
Next i
If flag Then
MsgBox "Choisir un article !"
Exit Sub
End If
ligne = Range("A" & Application.Rows.Count).End(xlUp).Row + 1
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) = True Then
Range("A" & ligne).Value = ListBox1.List(i, 0)
Range("B" & ligne).Value = ListBox1.List(i, 1)
Range("C" & ligne).Value = Val(ListBox1.List(i, 2))
Range("D" & ligne).Value = Val(ListBox1.List(i, 3))
ligne = ligne + 1
End If
Next i
Me.Hide
End Sub
Mon problème se pose pour les cellules suivantes:
Range("C" & ligne).Value = Val(ListBox1.List(i, 2))
Range("D" & ligne).Value = Val(ListBox1.List(i, 3))