1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| Private Sub T1_Change()
Dim i&, fin&, y&, a&, mem As Boolean
Application.ScreenUpdating = 0
If mem1 Then Exit Sub
If T1 = "" Then ListBox1.Clear: T2 = "": T3 = "": T4 = "": T5 = "": C3.Visible = 0: C4.Visible = 0: Exit Sub
ListBox1.Clear
' ici référence à l'array se trouve dans la même feuille que le userform
With Feuil1
y = 1
fin = .Range("A" & Rows.Count).End(xlUp).Row
aa = .Range("A2:F" & fin)
End With
For i = 1 To UBound(aa)
aa(i, 5) = i + 1
Next i
For i = 1 To UBound(aa)
For a = 1 To UBound(aa, 2)
If aa(i, a) Like "*" & T1 & "*" Then aa(i, 6) = "oui": y = y + 1: Exit For
Next a
Next i
If y = 1 Then Exit Sub
If y = 2 Then
' de 1 à l'indice 8
For i = 1 To UBound(aa)
If aa(i, 6) = "oui" Then
ListBox1.AddItem aa(i, 1)
' de l 'indice 1 à l'indice 4
For a = 1 To UBound(aa, 2) - 2
ListBox1.List(ListBox1.ListCount - 1, a - 1) = aa(i, a)
Controls("T" & a + 1) = aa(i, a)
Next a
mem = 1: Exit For
End If
Next i
Else
ReDim bb(y - 1, UBound(aa, 2) - 1)
y = 1
For i = 1 To UBound(aa)
If aa(i, 6) = "oui" Then
For a = 1 To UBound(aa, 2) - 1
bb(y, a) = aa(i, a)
Next a
y = y + 1
End If
Next i
End If
With ListBox1
.ColumnCount = 5
.ColumnWidths = "80;80;50;80;0"
If mem Then Exit Sub
.List = bb
End With
End Sub |
Partager