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
| Public Sub essai_tablo()
Dim lacel As Range
Dim tablo()
'ton critère de tri
lachaîne = Range("L2").Value
n = 0
'balayage des lignes informées hors les titres de colonnes
For i = 2 To Cells(Rows.Count, 1).End(xlUp).Row
Set lacel = Range("A" & i)
With lacel
If .Value = lachaîne Then
n = n + 1
'Alimentation du tableau dans la limite de 10 valeurs
If n <= 10 Then
ReDim Preserve tablo(1 To 3, 1 To n)
'Dans l'ordre : Nom, Article, Prix
For k = 1 To 3
tablo(k, n) = .Offset(0, k - 1).Value
Next k
End If
End If
End With
Next i
'Information de la feuille des résultats
Range([G2], [I2].Offset(UBound(tablo, 2) - 1, 0)).Value = WorksheetFunction.Transpose(tablo)
Set lacel = Nothing
Erase tablo
End Sub |
Partager