Hello,
Voici le code utilisé :
Private Sub ListBox1_Change()
If bTest Then
Exit Sub
End If
sTemp = ""
For i = 0 To Me.ListBox1.ListCount - 1
If Me.ListBox1.Selected(i) Then
sTemp = sTemp & Me.ListBox1.List(i) & "-"
End If
Next
On Error Resume Next
Err.Clear
sTemp = VBA.Left(sTemp, VBA.Len(sTemp) - 1)
If Err.Number <> 0 Then
sTemp = ""
End If
On Error GoTo 0
ActiveCell = sTemp
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column = 41 And Target.Row > 2 Then
With Me.ListBox1
.MultiSelect = fmMultiSelectMulti
.ListStyle = fmListStyleOption
.Height = 150
.Width = 100
.Top = ActiveCell.Top
.Left = ActiveCell.Offset(0, 1).Left
.Visible = True
End With
On Error Resume Next
'i = Application.WorksheetFunction.Match(Cells(ActiveCell.Row, 2), Worksheets("Donnée").Range("Familles"), 0) - 1
i = 0
If Worksheets("Feuil3").Range("O1").Offset(0, i).End(xlDown).Row = 2 Then
Me.ListBox1.List = Array(Worksheets("Feuil3").Range(Worksheets("Feuil3").Range("O1").Offset(1, i), _
Worksheets("Feuil3").Range("O1").Offset(0, i).End(xlDown)).Value, "")
Else
Me.ListBox1.List = Worksheets("Feuil3").Range(Worksheets("Feuil3").Range("O1").Offset(1, i), _
Worksheets("Feuil3").Range("O1").Offset(0, i).End(xlDown)).Value
End If
On Error GoTo 0
a = VBA.Split(ActiveCell, "-")
If UBound(a) >= 0 Then
For i = 0 To Me.ListBox1.ListCount - 1
If Not IsError(Application.Match(Me.ListBox1.List(i), a, 0)) Then
bTest = True
Me.ListBox1.Selected(i) = True
bTest = False
End If
Next
End If
Else
Me.ListBox1.Visible = False
End If
Merci