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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
| Sub CalculMontante1()
Dim DerLig As Long
Dim M As Byte
Dim DernCol As Integer
Dim i As Long
Dim GB As Integer, Val1 As Integer, Val2 As Integer
Dim rng As Range
'Dernière ligne vide et colonne
'DerLig = Range("V" & Rows.Count).End(xlUp).Row '+ 1
DerLig = [V65536].End(xlUp).Row
DernCol = Cells(DerLig, Cells.Columns.Count).End(xlToLeft).Column '+ 3 'colonne U
With Feuil2
'Mise 1-4-7-10 = 1+3= 4 +3= 7 +3= 10
'For m = 1 To 10 Step 3
i = DerLig + 1
If .Range("B" & i) = .Range("G" & i) Then
'Result SI(NB.SI(B4;G4)=0;"P";"G")
.Range("V" & i) = "G"
'Cote SI(V4="P";0;M4)
.Range("W" & i) = .Range("L" & i)
'Mise
.Range("X" & i) = 1
'*************************************************************************
'GAIN BRUT SI(X4="";"";W4*X4)
'Range("Z" & i) = Range("W" & i) * Range("X" & i)
Val1 = .Range("W" & i)
Val2 = .Range("X" & i)
GB = GainBrut(Val1, Val2)
.Range("Z" & i) = GB
'*************************************************************************
'Cumul mise SOMME($X$4:X4)
.Range("Y" & i).FormulaLocal = "=SOMME($X$4:X4)"
'Cumul Gain SI(X4="";"";SOMME($Z$4:Z4))
.Range("AA" & i).FormulaLocal = "=SOMME($Z$4:Z4)"
'Résultat net SI(X4="";"";SOMME($Z$4:Z4)-SOMME($X$4:X4))
.Range("AB" & i).FormulaLocal = "=SOMME($Z$4:Z4)-SOMME($X$4:X4)"
Else
.Range("V" & i) = "P"
'Mise
.Range("X" & i) = 1
'**********************************************************************
'GAIN BRUT
'Range("Z" & i) = Range("W" & i) * Range("X" & i)
Val1 = .Range("W" & i)
Val2 = .Range("X" & i)
GB = GainBrut(Val1, Val2)
.Range("Z" & i) = GB
'**********************************************************************
'CUMUL MISE
'.Range("Y" & i).FormulaLocal = "=SOMME($X$4:X4)"
rng = Range("$X$4:X" & i)
.Range("Y" & i) = CumulMise(rng)
'Cumul Gain SI(X4="";"";SOMME($Z$4:Z4))
.Range("AA" & i).FormulaLocal = "=SOMME($Z$4:Z4)"
'Résultat net SI(X4="";"";SOMME($Z$4:Z4)-SOMME($X$4:X4))
.Range("AB" & i).FormulaLocal = "=SOMME($Z$4:Z4)-SOMME($X$4:X4)"
End If
'Next
End With
End Sub
'**************************************************************
Function GainBrut(Val1 As Integer, Val2 As Integer) As Integer
GainBrut = Val1 * Val2
End Function
'**************************************************************
Public Function CumulMise(rng As Range)
CumulMise = WorksheetFunction.Sum(rng)
End Function |