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 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
|
With Sheets("Data_lait").ListObjects("Données_Lait")
If .ListRows.Count = 0 Then
Range("Données_Lait[[#Headers],[Date]]").Offset(1, 0) = 1
Range("Données_Lait[[#Headers],[Date]]").Offset(1, 0) = ""
End If
If .ListRows.Count = 1 And .ListRows(1).Range.Cells(1, 1) = "" Then
Set LignTablo = Sheets("Data_lait").ListObjects("Données_Lait").ListRows(1)
Else
Set LignTablo = Range("Données_Lait").ListObject.ListRows.Add(AlwaysInsert:=True)
End If
End With
With LignTablo.Range
.Cells(1, 1) = TrouveType(TxtDate)
.Cells(1, 2) = TrouveType(TxtLivraisonpossible)
.Cells(1, 3) = TrouveType(TxtDatefincampagne)
.Cells(1, 4) = TrouveType(TxtNbmoyenVLcampagne)
.Cells(1, 5) = TrouveType(TxtLaittank)
.Cells(1, 6) = TrouveType(TxtTraitetank)
.Cells(1, 7) = TrouveType(TxtVltank)
.Cells(1, 8) = TrouveType(TxtDatelaitréalisé)
.Cells(1, 9) = TrouveType(TxtLaitréalisé)
.Cells(1, 10) = TrouveType(TxtVlfincampagne)
.Cells(1, 11) = TrouveType(TxtMoispaye)
.Cells(1, 12) = TrouveType(TxtPrixlaitnet)
.Cells(1, 13) = TrouveType(TxtTb)
.Cells(1, 14) = TrouveType(TxtTp)
.Cells(1, 15) = TrouveType(TxtUrée)
.Cells(1, 16) = TrouveType(TxtCellules)
'Calcul Nb moyen Vl depuis le début de la campagne
Set SrcRng = ThisWorkbook.Worksheets("Data_Lait").Range("A5").CurrentRegion
CntVal = 0
SumVal = 0
For RowN = 2 To SrcRng.Rows.Count
If IsDate(SrcRng(RowN, 1)) Then 'Peut être supprimé si c'est toujours une date
DMonth = Month(SrcRng(RowN, 1))
Debug.Print RowN, SrcRng(RowN, 1), DMonth
If DMonth = 4 Then
CntVal = 0
SumVal = 0
End If
CntVal = CntVal + 1
SumVal = SumVal + SrcRng(RowN, 7)
SrcRng(RowN, 17) = SumVal / CntVal
End If
Next RowN
'calcul du lait total restant à livrer
.Cells(1, 18) = Val(TrouveType(TxtLivraisonpossible) - Val(TrouveType(TxtLaitréalisé)))
'calcul lait à livrer par vl par jour sur la campagne
If Val(TrouveType(TxtNbmoyenVLcampagne)) = 0 Then
.Cells(1, 19) = 0
Else: .Cells(1, 19) = Val(TrouveType(TxtLivraisonpossible)) / 365 / Val(TrouveType(TxtNbmoyenVLcampagne))
End If
'calcul lait livré par vl depuis début de campagne
If IsDate(TxtDatefincampagne) * IsDate(TxtDatelaitréalisé) * Sheets("Fiche").Range("VL_moyen_depuis_début_campagne") = 0 Then
.Cells(1, 20) = 0
Else: .Cells(1, 20) = Val((TrouveType(TxtLaitréalisé)) / (365 - (CDate(TrouveType(TxtDatefincampagne)) - CDate(TrouveType(TxtDatelaitréalisé))))) / Sheets("Fiche").Range("VL_moyen_depuis_début_campagne")
End If
'calcul lait restant à livrer par vl jusqu'à fin de campagne
If IsDate(TxtDatefincampagne) * IsDate(TxtDatelaitréalisé) * Val(TrouveType(TxtVlfincampagne)) = 0 Then
.Cells(1, 21) = 0
Else: .Cells(1, 21) = (Val(TrouveType(TxtLivraisonpossible)) - Val(TrouveType(TxtLaitréalisé))) / (CDate(TrouveType(TxtDatefincampagne)) - CDate(TrouveType(TxtDatelaitréalisé))) / Val(TrouveType(TxtVlfincampagne))
End If
'Calcul PL réelle/ VL/jour
If Val(TrouveType(TxtLaittank)) * Val(TrouveType(TxtVltank)) = 0 Then
.Cells(1, 22) = 0
Else: .Cells(1, 22) = Val(TrouveType(TxtLaittank)) / Val(TrouveType(TxtVltank)) / (Val(TrouveType(TxtTraitetank)) / 2)
End If
'Calcul lait à 70 par VL par jour
If Val(TrouveType(TxtLaittank)) * Val(TrouveType(TxtVltank)) = 0 Then
.Cells(1, 23) = 0
Else: .Cells(1, 23) = Val(TrouveType(TxtLaittank)) / Val(TrouveType(TxtVltank)) / (Val(TrouveType(TxtTraitetank)) / 2) * (Val(TrouveType(TxtTb)) + Val(TrouveType(TxtTp))) / 70
End If
'Calcul MU par VL /jour
If Val(TrouveType(TxtLaittank)) * Val(TrouveType(TxtVltank)) = 0 Then
.Cells(1, 24) = 0
Else: .Cells(1, 24) = Val(TrouveType((TxtLaittank)) / Val(TrouveType(TxtVltank)) / (Val(TrouveType(TxtTraitetank)) / 2)) * (Val(TrouveType(TxtTb)) + Val(TrouveType(TxtTp)))
End If
'Calcul lait vendu par VL /jour
If Val(TrouveType(TxtLaittank)) * Val(TrouveType(TxtVltank)) * Val(TrouveType(TxtTraitetank)) * Val(TrouveType(TxtPrixlaitnet)) = 0 Then
.Cells(1, 25) = 0
Else: .Cells(1, 25) = (Val(TrouveType((TxtLaittank)) / Val(TrouveType(TxtVltank)) / (Val(TrouveType(TxtTraitetank)) / 2)) * Val(TrouveType(TxtPrixlaitnet))) / 1000
End If
'Calcul cout ration / 1000 L
If Val(TrouveType(TxtLaittank)) * Val(TrouveType(TxtVltank)) * Val(TrouveType(TxtTraitetank)) * Val(TrouveType(TxtPrixlaitnet)) = 0 Then
.Cells(1, 26) = 0
Else: .Cells(1, 26) = Val(TrouveType(Sheets("Fiche").Range("cout_ration_VL_j_Ration_Initiale") * 1000)) / (Val(TrouveType(TxtLaittank)) / Val(TrouveType(TxtVltank)) / (Val(TrouveType(TxtTraitetank)) / 2))
End If
End With
Unload Me
End Sub |