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
| Option Explicit
Sub Exemple()
Dim t As Date
t = Timer
Dim tableau0
Dim tableau1
Dim tableau2(1 To 200, 1 To 100)
Dim derniereLigne As Long '--- Long
Dim Somme As Single
Dim i As Long, j As Long, k As Long, ub1 As Long, a As Long
With Sheets("Exercice")
derniereLigne = .Cells(Rows.Count, 1).End(xlUp).Row
tableau0 = .Range("A1:B" & derniereLigne).Value
tableau1 = tableau0
ub1 = UBound(tableau1)
ReDim Preserve tableau1(1 To UBound(tableau0), 1 To 202)
For k = 2 To 200
For j = k - 1 To ub1
Somme = 0
For i = j + 2 - k To j
Somme = Somme + tableau1(i, 1)
tableau1(j, k + 2) = Somme / k
Next
Next
Next
For k = 1 To 200
For j = 1 To 100
For i = 2 To ub1
If tableau1(i, 2) > j Then
If tableau1(i, k + 2) > tableau1(i - 1, k + 2) Then
tableau1(i, 3) = 1
End If
End If
If tableau1(i, 3) = 1 Then
a = 1
Else
a = 0
End If
Next
tableau2(k, j) = a
Next
Next
.Range("S1").Resize(UBound(tableau2, 1), UBound(tableau2, 2)).Value = tableau2
End With
MsgBox Timer - t
End Sub |
Partager