Bonjour à tous,
Je souhaite créer un nouveau tableau dans une boucle en fonction d'indices et de variables, pour ensuite l'écrire sur ma feuille.
Malheureusement, je m'y prends comme un manche. Mon "tableau2(K, L) = a", c'est n'importe quoi.
Le but du jeu, c'est d'avoir un résultat équivalant à Cells(K, L + 20) = a.
(+ 20 pour le décalage sur ma feuille)
Ça doit être simple, mais je ne sais pas faire. Une solution ?
Sub Exemple()
t = Timer
Dim tableau0
Dim tableau1
Dim tableau2
Dim derniereLigne As Integer
Dim I As Integer
With Sheets("Exercice")
derniereLigne = .Cells(Rows.Count, 1).End(xlUp).Row
tableau0 = .Range("A1:B" & derniereLigne).Value
tableau1 = tableau0
ReDim Preserve tableau1(1 To UBound(tableau0), 1 To 202)
For K = 2 To 200
For j = K - 1 To UBound(tableau1)
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 L = 1 To 100
For I = 2 To UBound(tableau1)
For j = K To K
If tableau1(I, j + 2) > tableau1(I - 1, j + 2) And tableau1(I, 2) > L Then
tableau1(I, 3) = 1
End If
a = 0
If tableau1(I, 3) = 1 Then
a = a + tableau1(I, 3)
End If
Next
Next
tableau2(K, L) = a 'ça marche pas
Next
Next
.Range("S1").Resize(UBound(tableau2, 1), UBound(tableau2, 2)).Value = tableau2
End With
MsgBox Timer - t
End Sub