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
|
Sub test2()
Dim Nbre As Long, i As Long, k As Long
Dim Kd() As Double, S As Double
With Sheets("Calcul")
Nbre = .Cells(.Rows.Count, 1).End(xlUp).Row
Tb = .Range("A1:Y" & Nbre)
For i = 1 To Nbre
If Tb(i, 16) = "EUR" Then
If Tb(i, 11) > 0 Then
k = k + 1
ReDim Preserve Kd(1 To 3, 1 To k)
Kd(1, k) = Tb(i, 11)
Kd(2, k) = Tb(i, 17)
Kd(3, k) = Kd(1, k) * Kd(2, k)
S = S + Kd(3, k)
End If
End If
Next i
.Range("BuyEUR").Value = S
End With
With Sheets("Calcul")
Nbre = .Cells(.Rows.Count, 1).End(xlUp).Row
Tb = .Range("A1:Y" & Nbre)
For i = 1 To Nbre
If Tb(i, 16) = "USD" Then
If Tb(i, 11) > 0 Then
k = k + 1
ReDim Preserve Kd(1 To 3, 1 To k)
Kd(1, k) = Tb(i, 11)
Kd(2, k) = Tb(i, 17)
Kd(3, k) = Kd(1, k) * Kd(2, k)
S = S + Kd(3, k)
End If
End If
Next i
.Range("BuyUSD").Value = S
End With
End Sub |