Bonsoir
J’ai realisé une macro et je souhaiterais calculer mon chiffre d’affaires désaisonnalisé colonne H en fonction des coefficients trimestriels, T1 T2 T3 et T4 afin d’obtenir les résultats suivants, mais en vain je n’arrive pas à trouver la solution en VBA.
Colonne K
T1 k7 = 0,864
T2 K8= 1,501
T3 K9= 1,249
T4 K10= 0,386
Le calcul avec excel sont les suivants :
=B2/K7
=B3/K8
=B4/K9
=B5/K10
=B6/K7
=B7/K8
=B8/K9
=B9/K10
….
xi yi Chiffre d'affaires désaisonnalisé
1 240 278
2 420 280
3 370 296
4 110 285
5 250 289
6 440 293
7 360 288
8 115 298
9 270 312
10 480 320
11 400 320
12 130 337
Merci pour votre aide
Bien cordialement
J’ai realisé une macro et je souhaiterais calculer mon chiffre d’affaires désaisonnalisé colonne H en fonction des coefficients trimestriels, T1 T2 T3 et T4 afin d’obtenir les résultats suivants, mais en vain je n’arrive pas à trouver la solution en VBA.
Colonne K
T1 k7 = 0,864
T2 K8= 1,501
T3 K9= 1,249
T4 K10= 0,386
Le calcul avec excel sont les suivants :
=B2/K7
=B3/K8
=B4/K9
=B5/K10
=B6/K7
=B7/K8
=B8/K9
=B9/K10
….
xi yi Chiffre d'affaires désaisonnalisé
1 240 278
2 420 280
3 370 296
4 110 285
5 250 289
6 440 293
7 360 288
8 115 298
9 270 312
10 480 320
11 400 320
12 130 337
Merci pour votre aide
Bien cordialement
Code:
Sub calCoeff()
Dim i As Integer
Dim DerLig As Long
Dim Serie_Y As Variant, Serie_X As Variant
With Worksheets("Moyenne_Mobile")
DerLig = .Range("A" & .Rows.Count).End(xlUp).Row
For i = 2 To DerLig - 2
.Cells(i + 1, 3).Value = Application.WorksheetFunction.Average(.Range(.Cells(i, 2), .Cells(i + 3, 2)))
Next i
For i = 2 To DerLig - 2
.Cells(i + 2, 4).Value = Application.WorksheetFunction.Average(.Range(.Cells(i + 1, 3), .Cells(i + 2, 3)))
Next i
.Range(.Cells(DerLig - 1, 4), .Cells(DerLig, 4)).ClearContents
End With
'Traitement des données
Set Serie_Y = Range("D4:D11")
Set Serie_X = Range("E4:E11")
Range("J4:K4").Value = Application.WorksheetFunction.LinEst(Serie_Y, Serie_X)
'3eme boucle de traitement
For i = 2 To DerLig
Cells(i, 6).Value = Range("j4").Value * Cells(i, 5).Value + Range("k4").Value
If Cells(i, 6).Value <> 0 Then
Cells(i, 7).Value = Cells(i, 2).Value / Cells(i, 6).Value
End If
'Cells(i, 8).Value = Cells(i, 2).Value / Cells(i, 7).Value
Next i
'calcul des Coefficients saisonniers trimestriels
Trim1 = (Range("g2").Value + Range("g6").Value + Range("g10").Value) / 3
Trim2 = (Range("g3").Value + Range("g7").Value + Range("g11").Value) / 3
Trim3 = (Range("g4").Value + Range("g8").Value + Range("g12").Value) / 3
Trim4 = (Range("g5").Value + Range("g9").Value + Range("g13").Value) / 3
' affichage des Coefficients saisonniers trimestriels
Cells(7, 11).Value = Trim1
Cells(8, 11).Value = Trim2
Cells(9, 11).Value = Trim3
Cells(10, 11).Value = Trim4
'4eme boucle de traitement
'For i = 2 To DerLig
' Cells(i, 8).Value = Cells(i, 1).Value.Value * Trim1
'Next i
End Sub