1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| Sub SelectionnerElementsCommuns()
Dim i As Integer, j As Integer
Dim listBox1 As Object, listBox2 As Object
Set listBox1 = UserForm1.ListBox1
Set listBox2 = UserForm1.ListBox2
' Parcours des éléments de la première ListBox
For i = 0 To listBox1.ListCount - 1
' Vérifier si l'élément est sélectionné dans ListBox1
If listBox1.Selected(i) = True Then
' Parcours des éléments de la deuxième ListBox
For j = 0 To listBox2.ListCount - 1
' Vérifier si l'élément est identique
If listBox1.List(i) = listBox2.List(j) Then
listBox2.Selected(j) = True
End If
Next j
End If
Next i
End Sub |
Partager