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
| Sub getCashFlow()
Dim i As Integer
Dim j As Integer
Dim f As Integer
Dim start As Single
Dim a As Integer
Dim b As Integer
start = Timer
For i = 13 To 25 'vérifier valeur max de i'
For j = 16 To 380 'vérifier valeur max de j'
If Cells(i, 13).Value = 0 Or Cells(i, 13).Value <> Cells(i, 12).Value Then 'Si condition 1 (colonne "check" = 0 ou colonne "check"<>calendar), alors faire getCalendar puis getPrice'
GoTo getCalendar
GoTo getPrice
Else: Cells(i, 13).Value = Cells(i, 12).Value 'Si condition 2 (colonne "check"= colonne "calendar"), alors SEULEMENT getPrice'
GoTo getPrice
End If
Next j
Next i
getCalendar:
For i = 13 To 25 'vérifier valeur max de i'
For j = 16 To 380 'vérifier valeur max de j'
If Cells(i, 12).Value = "A" Then f = 2
If Cells(i, 12).Value = "B" Then f = 3
If Cells(i, 12).Value = "C" Then f = 4 'différentes valeurs de f à màj'
Cells(i, j).Value = Application.VLookup(Cells(12, j), Sheet2.Range("D6:G370"), f, True) 'vérifier limite du tableau pour le vlookup'
Next j
Next i
getPrice:
For a = 13 To 25 'vérifier valeur max de a'
For b = 16 To 380 'vérifier valeur max de b'
If Cells(12, b).Value >= WorksheetFunction.Min(Cells(a, 9).Value, Cells(a, 10).Value) And Cells(12, b).Value <= WorksheetFunction.Max(Cells(a, 9).Value, Cells(a, 10).Value) And Cells(a, b).Value <> 1 Then 'vérifier que cette ligne utilise bien les colonnes "Start Date" (Cells(a, 9).Value) et "Finish Date" (Cells(a,10)'
Cells(a, b).Value = Cells(a, 14).Value 'vérifier que cette ligne renvoie bien à la colonne "Daily Price"'
Else: Cells(a, b).Value = Cells(a, b).Value
End If
Next b
Next a
For i = 13 To 25 'vérifier valeur max de i'
Cells(i, 13) = Cells(i, 12)
Next i
MsgBox "durée du traitement : " & Timer - start & "secondes"
End Sub |
Partager