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
| Private Sub T1_Change()
Dim i&, aa, a&, bb, y&, sh, cc
If T1 = "" Then L1.Clear: Label2 = "": Exit Sub
y = 1
ReDim bb(4, y)
For Each sh In Worksheets
With sh
aa = .Range("A2:E" & .Range("A" & Rows.Count).End(xlUp).Row)
For i = 1 To UBound(aa)
If aa(i, 1) Like T1 & "*" Then
ReDim Preserve bb(4, y)
bb(1, y) = aa(i, 1): bb(2, y) = aa(i, 2): bb(3, y) = aa(i, 4): y = y + 1
End If
Next i
End With
Next sh
If y = 1 Then Exit Sub
If y = 2 Then
ReDim cc(1, 3)
cc(1, 1) = bb(1, 1): cc(1, 2) = bb(2, 1): cc(1, 3) = bb(3, 1)
L1.List = cc
Else
L1.List = Application.Transpose(bb)
End If
If y = 2 Then
Label2 = "Vous avez trouvé " & y - 1 & " ligne avec la recherche " & T1
Else
Label2 = "Vous avez trouvé " & y - 1 & " lignes avec la recherche " & T1
End If
L1.ColumnCount = 3
L1.ColumnWidths = "280;280;80"
End Sub |
Partager