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 60 61 62 63 64 65 66 67
| Sub tableau()
Dim zone As Variant
Dim tabloa() As Variant
Dim tablob() As Variant
Dim tabloc() As Variant
Dim tablod() As Variant
Dim tabloe() As Variant
Dim tablof() As Variant
Dim i As Byte, c As Byte, d As Byte, e As Byte, f As Byte, g As Byte, h As Byte
Application.ScreenUpdating = False
Workbooks("toto").Activate
Sheets("Feuil1").Select
zone = Range("A1").CurrentRegion
le problème se situe ici sur Ubound(zone,1) si zone >255
For i = LBound(zone, 1) To UBound(zone, 1)
If zone(i, 4) = "XXXX" Then
c = c + 1
ReDim Preserve tabloa(c)
tabloa(c) = Application.Index(zone, i)
tablo(1, 1) = c
'trouve la valeur min et l'écrit dans le tableau de synthèse
tablo(1, 2) = Application.Min(Application.Index(tabloa, , 3))
'trouve la valeur max et l'écrit dans le tableau de synthèse
tablo(1, 3) = Application.Max(Application.Index(tabloa, , 3))
'quantité inf 1000 et l'écrit dans le tableau de synthèse
If Application.Min(Application.Index(tabloa(c), , 3)) < 1000 Then
tablo(1, 4) = tablo(1, 4) + 1
End If
'quantité 1000/2000 et l'écrit dans le tableau de synthèse
If Application.Min(Application.Index(tabloa(c), , 3)) >= 1000 And Application.Min(Application.Index(tabloa(c), , 3)) < 2000 Then
tablo(1, 5) = tablo(1, 5) + 1
End If
'quantité 2000/3000 et l'écrit dans le tableau de synthèse
If Application.Min(Application.Index(tabloa(c), , 3)) >= 2000 And Application.Min(Application.Index(tabloa(c), , 3)) < 3000 Then
tablo(1, 6) = tablo(1, 6) + 1
End If
'quantité sup 3000 et l'écrit dans le tableau de synthèse
If Application.Min(Application.Index(tabloa(c), , 3)) >= 3000 Then
tablo(1, 7) = tablo(1, 7) + 1
End If
'calculs la moyenne et l'écrit dans le tableau de synthèse
tablo(1, 8) = Application.Average(Application.Index(tabloa, , 3))
End If |
Partager