Autres VBA aide macro

SKN-44

XLDnaute Nouveau
Bonjour

Je suis nouveau dans le forum

Avant bonjour à tous

je travaille sur un sujet et j'ai un macro qui ne fonctionne pas
J'ai programmé la macro en sorte quelle consomme une valeur mais dans ma simulation elle consomme la moitié d'une valeur
J'aimerais savoir d'où peux provenir l'erreur ?


MERCI d'avance
 

Staple1600

XLDnaute Barbatruc
Bonsoir le fil

SKN-44
La première erreur, c'est le titre de ta discussion.
La seconde, c'est de ne pas avoir lu la charte du forum
Heureusement, tu peux facilement corriger ces deux erreurs en moins de 3 minutes et 33 secondes ;)

En attendant, je souhaite la bienvenue sur le forum ;)
 

Eric C

XLDnaute Barbatruc
Bonsoir le forum
Bonsoir SKN-44, bonsoir Staple1600 (pas rafraîchi)

Bienvenu sur le forum. Primo, Ne Pas Crier (écrire en majuscule = crier sur un forum). Secondo : Il n'y a jamais d'urgence, ici, les membres sont bénévoles donc disposent de leur temps pour répondre - Tertio : nos amis, les pros, ne pourront t'aider qu'en visualisant le code de ton fichier. Place en donc un, anonymisé.
Bonne soirée à toutes & à tous
 

SKN-44

XLDnaute Nouveau
'Avancement du convois clt, impact sur les bacs vides et avant fab clt

If etat_convoi_clt <> 0 Then
If etat_convoi_clt > convoi_clt Then
etat_convoi_clt = etat_convoi_clt - convoi_clt ' ??????
End If
If etat_convoi_clt <= tps_prod_clt + pas - 0.000001 Then
If stk_avant_fab_clt < (bac_convoi_clt * (tps_prod_clt - etat_convoi_clt)) Then
conso_possible4 = 0
manque_plein_clt = bac_convoi_clt - stk_avant_fab_clt ' ???
flag_clt = 1
Else
conso_possible4 = nb_um_jour * pas_fab_clt
End If
If etat_convoi_clt <= pas Then
If stk_avant_fab_clt < bac_convoi_clt Then
conso_possible5 = 0 ' il met une consommation de 0 si le bac convoi clt est > stock avant fab clt
manque_plein_clt = bac_convoi_clt - stk_avant_fab_clt
flag_clt = 1
Else
conso_possible5 = bac_convoi_clt * etat_convoi_clt
End If
Else
conso_possible5 = nb_um_jour * pas_fab_clt
End If
If etat_convoi_clt > tps_prod_clt Then
conso_possible6 = bac_convoi_clt * WorksheetFunction.Min(pas, pas - etat_convoi_clt + tps_prod_clt) '?????
Else
conso_possible6 = nb_um_jour * pas_fab_clt
End If
conso_possible_clt = WorksheetFunction.Min(conso_possible4, conso_possible5, conso_possible6)

If stk_avant_fab_clt >= bac_convoi_clt * (tps_prod_clt - etat_convoi_clt) Then
stk_avant_fab_clt = stk_avant_fab_clt - conso_possible_clt ' ici on va soustraire du stock dispo avant fab clt la conso du clt par pas de calcul
stk_vide_clt = stk_vide_clt + conso_possible_clt ' notre stock vide clt serait notre conso par pas de calcul
Else
manque_plein_clt = bac_convoi_clt - stk_avant_fab_clt
End If
End If
End If

'Avancement des fr?quences transport clt
'Condition : temps de transport < fr?quence de transport



If etat_trans_clt <> 0 Then
If etat_trans_clt >= tps_trans_clt Then
etat_trans_clt = 0
stk_vide_fnr = stk_vide_fnr + stk_trans_clt
stk_trans_clt = 0
Else
etat_trans_clt = etat_trans_clt + pas 'A ANALYSER ON DOIT PAS AVOIR 1 CAR LA CONDITION ETAIT QUE LE COMPTEUR SE MET A 0

End If
Else
If stk_trans_clt <> 0 Then
etat_trans_clt = etat_trans_clt + pas
End If
End If



If etat_freq_trans_clt <> 0 Then
If etat_freq_trans_clt >= freq_trans_clt Then
etat_freq_trans_clt = 0 ' ici la condition pour mettre le compteur ? 0
stk_trans_clt = stk_vide_clt 'le stock tpt clt prend la totalit? du stock vide clt
stk_vide_clt = 0 'le stock vide diminue
Else
etat_freq_trans_clt = etat_freq_trans_clt + pas '
End If
Else
etat_freq_trans_clt = etat_freq_trans_clt + pas ' on repasse de 0 ? 0.5
End If
'double controle pour remttre le compteur ? 0

If etat_freq_trans_clt <> 0 Then
If etat_freq_trans_clt >= freq_trans_clt Then
etat_freq_trans_clt = 0 ' ici la condition pour mettre le compteur ? 0
stk_trans_clt = stk_vide_clt 'le stock tpt clt prend la totalit? du stock vide clt
stk_vide_clt = 0 'le stock vide diminue
End If
End If








Sheets(2).Range("B4") = stk_vide_fnr 'Nbr de bacs
Sheets(2).Range("C4") = etat_stk_vide_fnr 'Temps d'attente ?coul? des bacs vides avant mise ? dispo fabrication
Sheets(2).Range("D4") = stk_vide_fab_fnr 'Nbr de bacs dispos pour la fabrication
Sheets(2).Range("D5") = manque_vide_fnr
Sheets(2).Range("E4") = etat_convoi_fnr 'Avancement de la fabrication pour le Fnr
Sheets(2).Range("F4") = stk_ec_fnr
Sheets(2).Range("G4") = stk_secu_fnr
Sheets(2).Range("H4") = etat_delai_avant_rpt_fnr
Sheets(2).Range("I4") = stk_plein_fnr
Sheets(2).Range("J4") = etat_freq_trans_fnr
Sheets(2).Range("K4") = stk_trans_fnr
Sheets(2).Range("L8") = etat_trans_fnr
Sheets(2).Range("K14") = stk_secu_clt
Sheets(2).Range("J14") = stk_plein_clt
Sheets(2).Range("I14") = etat_stk_plein_clt
Sheets(2).Range("H14") = stk_avant_fab_clt
Sheets(2).Range("H13") = manque_plein_clt
Sheets(2).Range("F14") = etat_convoi_clt
Sheets(2).Range("D14") = stk_vide_clt
Sheets(2).Range("C14") = etat_freq_trans_clt
Sheets(2).Range("B14") = stk_trans_clt
Sheets(2).Range("A8") = etat_trans_clt
Sheets(2).Range("E8") = i
'?criture donn?es sur feuille
Sheets(3).Cells(j, 1) = i
Sheets(3).Cells(j, 2) = stk_vide_fnr
Sheets(3).Cells(j, 3) = etat_stk_vide_fnr
Sheets(3).Cells(j, 4) = stk_vide_fab_fnr
Sheets(3).Cells(j, 5) = etat_convoi_fnr
Sheets(3).Cells(j, 6) = stk_ec_fnr
Sheets(3).Cells(j, 7) = stk_secu_fnr
Sheets(3).Cells(j, 8) = etat_delai_avant_rpt_fnr
Sheets(3).Cells(j, 9) = stk_plein_fnr
Sheets(3).Cells(j, 10) = etat_freq_trans_fnr
Sheets(3).Cells(j, 11) = stk_trans_fnr
Sheets(3).Cells(j, 12) = etat_trans_fnr
Sheets(3).Cells(j, 13) = stk_secu_clt
Sheets(3).Cells(j, 14) = stk_plein_clt
Sheets(3).Cells(j, 15) = etat_delai_avant_fab_clt
Sheets(3).Cells(j, 16) = stk_avant_fab_clt
Sheets(3).Cells(j, 17) = etat_convoi_clt
Sheets(3).Cells(j, 18) = stk_vide_clt
Sheets(3).Cells(j, 19) = etat_freq_trans_clt
Sheets(3).Cells(j, 20) = stk_trans_clt
Sheets(3).Cells(j, 21) = etat_trans_clt
Sheets(3).Cells(j, 22) = manque_vide_fnr
Sheets(3).Cells(j, 23) = manque_plein_clt
Sheets(3).Cells(j, 24) = flag_fnr
Sheets(3).Cells(j, 25) = flag_clt

If flag = 0 Then
stk_vide_fnr = 0
Sheets(2).Range("B4") = stk_vide_fnr
Sheets(3).Cells(j, 2) = stk_vide_fnr
etat_convoi_fnr = etat_convoi_fnr + pas
End If
If stk_vide_fnr <> 0 Then
etat_stk_vide_fnr = etat_stk_vide_fnr + pas
End If
If stk_vide_fab_fnr <> 0 Then
If flag = 1 Then
etat_convoi_fnr = etat_convoi_fnr + pas
If etat_convoi_fnr > convoi_fnr Then
etat_convoi_fnr = etat_convoi_fnr - convoi_fnr
End If
End If
End If
If stk_plein_clt <> 0 Then
etat_stk_plein_clt = etat_stk_plein_clt + pas
End If

If stk_avant_fab_clt <> 0 Then ' ON DECLENCHE LE COMPTEUR SI LE STOCK AV DISPO CLT > 0
etat_convoi_clt = etat_convoi_clt + pas ' LE COMPTEUR PASSE DE 0 A 0.5
If etat_convoi_clt >= convoi_clt Then
etat_convoi_clt = etat_convoi_clt - convoi_clt ' ??? LE COMPTEUR PASSE BIEN DE 0 A 0.5 DE 0.5 A 1 MAIS LA CONSO NE CHANGE PAS????
End If ' etat convoi clt passe ? 0
End If
If etat_convoi_clt <> 0 Then ' a effacer si marche pas
If etat_convoi_clt > convoi_clt Then
etat_convoi_clt = etat_convoi_clt - convoi_clt ' ??????
End If
If etat_convoi_clt <= tps_prod_clt + pas - 0.000001 Then
If stk_avant_fab_clt < (bac_convoi_clt * (tps_prod_clt - etat_convoi_clt)) Then
conso_possible4 = 0
manque_plein_clt = bac_convoi_clt - stk_avant_fab_clt ' ???
flag_clt = 1
Else
conso_possible4 = nb_um_jour * pas_fab_clt
End If
If etat_convoi_clt <= pas Then
If stk_avant_fab_clt < bac_convoi_clt Then
conso_possible5 = 0 ' il met une consommation de 0 si le bac convoi clt est > stock avant fab clt
manque_plein_clt = bac_convoi_clt - stk_avant_fab_clt
flag_clt = 1
Else
conso_possible5 = bac_convoi_clt * etat_convoi_clt
End If
Else
conso_possible5 = nb_um_jour * pas_fab_clt
End If
If etat_convoi_clt > tps_prod_clt Then
conso_possible6 = bac_convoi_clt * WorksheetFunction.Min(pas, pas - etat_convoi_clt + tps_prod_clt) '?????
Else
conso_possible6 = nb_um_jour * pas_fab_clt
End If
conso_possible_clt = WorksheetFunction.Min(conso_possible4, conso_possible5, conso_possible6)

If stk_avant_fab_clt >= bac_convoi_clt * (tps_prod_clt - etat_convoi_clt) Then
stk_avant_fab_clt = stk_avant_fab_clt - conso_possible_clt ' ici on va soustraire du stock dispo avant fab clt la conso du clt par pas de calcul
stk_vide_clt = stk_vide_clt + conso_possible_clt ' notre stock vide clt serait notre conso par pas de calcul
Else
manque_plein_clt = bac_convoi_clt - stk_avant_fab_clt
End If
End If
End If

If flag = 0 Then
flag = 1
End If
'incr?mentation
i = i - 1
i = i + pas
j = j + 1

Next i

Sheets(4).Activate
End Sub
 

SKN-44

XLDnaute Nouveau
'Avancement du convois clt, impact sur les bacs vides et avant fab clt

If etat_convoi_clt <> 0 Then
If etat_convoi_clt > convoi_clt Then
etat_convoi_clt = etat_convoi_clt - convoi_clt ' ??????
End If
If etat_convoi_clt <= tps_prod_clt + pas - 0.000001 Then
If stk_avant_fab_clt < (bac_convoi_clt * (tps_prod_clt - etat_convoi_clt)) Then
conso_possible4 = 0
manque_plein_clt = bac_convoi_clt - stk_avant_fab_clt ' ???
flag_clt = 1
Else
conso_possible4 = nb_um_jour * pas_fab_clt
End If
If etat_convoi_clt <= pas Then
If stk_avant_fab_clt < bac_convoi_clt Then
conso_possible5 = 0 ' il met une consommation de 0 si le bac convoi clt est > stock avant fab clt
manque_plein_clt = bac_convoi_clt - stk_avant_fab_clt
flag_clt = 1
Else
conso_possible5 = bac_convoi_clt * etat_convoi_clt
End If
Else
conso_possible5 = nb_um_jour * pas_fab_clt
End If
If etat_convoi_clt > tps_prod_clt Then
conso_possible6 = bac_convoi_clt * WorksheetFunction.Min(pas, pas - etat_convoi_clt + tps_prod_clt) '?????
Else
conso_possible6 = nb_um_jour * pas_fab_clt
End If
conso_possible_clt = WorksheetFunction.Min(conso_possible4, conso_possible5, conso_possible6)

If stk_avant_fab_clt >= bac_convoi_clt * (tps_prod_clt - etat_convoi_clt) Then
stk_avant_fab_clt = stk_avant_fab_clt - conso_possible_clt ' ici on va soustraire du stock dispo avant fab clt la conso du clt par pas de calcul
stk_vide_clt = stk_vide_clt + conso_possible_clt ' notre stock vide clt serait notre conso par pas de calcul
Else
manque_plein_clt = bac_convoi_clt - stk_avant_fab_clt
End If
End If
End If

'Avancement des fr?quences transport clt
'Condition : temps de transport < fr?quence de transport



If etat_trans_clt <> 0 Then
If etat_trans_clt >= tps_trans_clt Then
etat_trans_clt = 0
stk_vide_fnr = stk_vide_fnr + stk_trans_clt
stk_trans_clt = 0
Else
etat_trans_clt = etat_trans_clt + pas 'A ANALYSER ON DOIT PAS AVOIR 1 CAR LA CONDITION ETAIT QUE LE COMPTEUR SE MET A 0

End If
Else
If stk_trans_clt <> 0 Then
etat_trans_clt = etat_trans_clt + pas
End If
End If



If etat_freq_trans_clt <> 0 Then
If etat_freq_trans_clt >= freq_trans_clt Then
etat_freq_trans_clt = 0 ' ici la condition pour mettre le compteur ? 0
stk_trans_clt = stk_vide_clt 'le stock tpt clt prend la totalit? du stock vide clt
stk_vide_clt = 0 'le stock vide diminue
Else
etat_freq_trans_clt = etat_freq_trans_clt + pas '
End If
Else
etat_freq_trans_clt = etat_freq_trans_clt + pas ' on repasse de 0 ? 0.5
End If
'double controle pour remttre le compteur ? 0

If etat_freq_trans_clt <> 0 Then
If etat_freq_trans_clt >= freq_trans_clt Then
etat_freq_trans_clt = 0 ' ici la condition pour mettre le compteur ? 0
stk_trans_clt = stk_vide_clt 'le stock tpt clt prend la totalit? du stock vide clt
stk_vide_clt = 0 'le stock vide diminue
End If
End If








Sheets(2).Range("B4") = stk_vide_fnr 'Nbr de bacs
Sheets(2).Range("C4") = etat_stk_vide_fnr 'Temps d'attente ?coul? des bacs vides avant mise ? dispo fabrication
Sheets(2).Range("D4") = stk_vide_fab_fnr 'Nbr de bacs dispos pour la fabrication
Sheets(2).Range("D5") = manque_vide_fnr
Sheets(2).Range("E4") = etat_convoi_fnr 'Avancement de la fabrication pour le Fnr
Sheets(2).Range("F4") = stk_ec_fnr
Sheets(2).Range("G4") = stk_secu_fnr
Sheets(2).Range("H4") = etat_delai_avant_rpt_fnr
Sheets(2).Range("I4") = stk_plein_fnr
Sheets(2).Range("J4") = etat_freq_trans_fnr
Sheets(2).Range("K4") = stk_trans_fnr
Sheets(2).Range("L8") = etat_trans_fnr
Sheets(2).Range("K14") = stk_secu_clt
Sheets(2).Range("J14") = stk_plein_clt
Sheets(2).Range("I14") = etat_stk_plein_clt
Sheets(2).Range("H14") = stk_avant_fab_clt
Sheets(2).Range("H13") = manque_plein_clt
Sheets(2).Range("F14") = etat_convoi_clt
Sheets(2).Range("D14") = stk_vide_clt
Sheets(2).Range("C14") = etat_freq_trans_clt
Sheets(2).Range("B14") = stk_trans_clt
Sheets(2).Range("A8") = etat_trans_clt
Sheets(2).Range("E8") = i
'?criture donn?es sur feuille
Sheets(3).Cells(j, 1) = i
Sheets(3).Cells(j, 2) = stk_vide_fnr
Sheets(3).Cells(j, 3) = etat_stk_vide_fnr
Sheets(3).Cells(j, 4) = stk_vide_fab_fnr
Sheets(3).Cells(j, 5) = etat_convoi_fnr
Sheets(3).Cells(j, 6) = stk_ec_fnr
Sheets(3).Cells(j, 7) = stk_secu_fnr
Sheets(3).Cells(j, 8) = etat_delai_avant_rpt_fnr
Sheets(3).Cells(j, 9) = stk_plein_fnr
Sheets(3).Cells(j, 10) = etat_freq_trans_fnr
Sheets(3).Cells(j, 11) = stk_trans_fnr
Sheets(3).Cells(j, 12) = etat_trans_fnr
Sheets(3).Cells(j, 13) = stk_secu_clt
Sheets(3).Cells(j, 14) = stk_plein_clt
Sheets(3).Cells(j, 15) = etat_delai_avant_fab_clt
Sheets(3).Cells(j, 16) = stk_avant_fab_clt
Sheets(3).Cells(j, 17) = etat_convoi_clt
Sheets(3).Cells(j, 18) = stk_vide_clt
Sheets(3).Cells(j, 19) = etat_freq_trans_clt
Sheets(3).Cells(j, 20) = stk_trans_clt
Sheets(3).Cells(j, 21) = etat_trans_clt
Sheets(3).Cells(j, 22) = manque_vide_fnr
Sheets(3).Cells(j, 23) = manque_plein_clt
Sheets(3).Cells(j, 24) = flag_fnr
Sheets(3).Cells(j, 25) = flag_clt

If flag = 0 Then
stk_vide_fnr = 0
Sheets(2).Range("B4") = stk_vide_fnr
Sheets(3).Cells(j, 2) = stk_vide_fnr
etat_convoi_fnr = etat_convoi_fnr + pas
End If
If stk_vide_fnr <> 0 Then
etat_stk_vide_fnr = etat_stk_vide_fnr + pas
End If
If stk_vide_fab_fnr <> 0 Then
If flag = 1 Then
etat_convoi_fnr = etat_convoi_fnr + pas
If etat_convoi_fnr > convoi_fnr Then
etat_convoi_fnr = etat_convoi_fnr - convoi_fnr
End If
End If
End If
If stk_plein_clt <> 0 Then
etat_stk_plein_clt = etat_stk_plein_clt + pas
End If

If stk_avant_fab_clt <> 0 Then ' ON DECLENCHE LE COMPTEUR SI LE STOCK AV DISPO CLT > 0
etat_convoi_clt = etat_convoi_clt + pas ' LE COMPTEUR PASSE DE 0 A 0.5
If etat_convoi_clt >= convoi_clt Then
etat_convoi_clt = etat_convoi_clt - convoi_clt ' ??? LE COMPTEUR PASSE BIEN DE 0 A 0.5 DE 0.5 A 1 MAIS LA CONSO NE CHANGE PAS????
End If ' etat convoi clt passe ? 0
End If
If etat_convoi_clt <> 0 Then ' a effacer si marche pas
If etat_convoi_clt > convoi_clt Then
etat_convoi_clt = etat_convoi_clt - convoi_clt ' ??????
End If
If etat_convoi_clt <= tps_prod_clt + pas - 0.000001 Then
If stk_avant_fab_clt < (bac_convoi_clt * (tps_prod_clt - etat_convoi_clt)) Then
conso_possible4 = 0
manque_plein_clt = bac_convoi_clt - stk_avant_fab_clt ' ???
flag_clt = 1
Else
conso_possible4 = nb_um_jour * pas_fab_clt
End If
If etat_convoi_clt <= pas Then
If stk_avant_fab_clt < bac_convoi_clt Then
conso_possible5 = 0 ' il met une consommation de 0 si le bac convoi clt est > stock avant fab clt
manque_plein_clt = bac_convoi_clt - stk_avant_fab_clt
flag_clt = 1
Else
conso_possible5 = bac_convoi_clt * etat_convoi_clt
End If
Else
conso_possible5 = nb_um_jour * pas_fab_clt
End If
If etat_convoi_clt > tps_prod_clt Then
conso_possible6 = bac_convoi_clt * WorksheetFunction.Min(pas, pas - etat_convoi_clt + tps_prod_clt) '?????
Else
conso_possible6 = nb_um_jour * pas_fab_clt
End If
conso_possible_clt = WorksheetFunction.Min(conso_possible4, conso_possible5, conso_possible6)

If stk_avant_fab_clt >= bac_convoi_clt * (tps_prod_clt - etat_convoi_clt) Then
stk_avant_fab_clt = stk_avant_fab_clt - conso_possible_clt ' ici on va soustraire du stock dispo avant fab clt la conso du clt par pas de calcul
stk_vide_clt = stk_vide_clt + conso_possible_clt ' notre stock vide clt serait notre conso par pas de calcul
Else
manque_plein_clt = bac_convoi_clt - stk_avant_fab_clt
End If
End If
End If

If flag = 0 Then
flag = 1
End If
'incr?mentation
i = i - 1
i = i + pas
j = j + 1

Next i

Sheets(4).Activate
End Sub'Avancement du convois clt, impact sur les bacs vides et avant fab clt

If etat_convoi_clt <> 0 Then
If etat_convoi_clt > convoi_clt Then
etat_convoi_clt = etat_convoi_clt - convoi_clt ' ??????
End If
If etat_convoi_clt <= tps_prod_clt + pas - 0.000001 Then
If stk_avant_fab_clt < (bac_convoi_clt * (tps_prod_clt - etat_convoi_clt)) Then
conso_possible4 = 0
manque_plein_clt = bac_convoi_clt - stk_avant_fab_clt ' ???
flag_clt = 1
Else
conso_possible4 = nb_um_jour * pas_fab_clt
End If
If etat_convoi_clt <= pas Then
If stk_avant_fab_clt < bac_convoi_clt Then
conso_possible5 = 0 ' il met une consommation de 0 si le bac convoi clt est > stock avant fab clt
manque_plein_clt = bac_convoi_clt - stk_avant_fab_clt
flag_clt = 1
Else
conso_possible5 = bac_convoi_clt * etat_convoi_clt
End If
Else
conso_possible5 = nb_um_jour * pas_fab_clt
End If
If etat_convoi_clt > tps_prod_clt Then
conso_possible6 = bac_convoi_clt * WorksheetFunction.Min(pas, pas - etat_convoi_clt + tps_prod_clt) '?????
Else
conso_possible6 = nb_um_jour * pas_fab_clt
End If
conso_possible_clt = WorksheetFunction.Min(conso_possible4, conso_possible5, conso_possible6)

If stk_avant_fab_clt >= bac_convoi_clt * (tps_prod_clt - etat_convoi_clt) Then
stk_avant_fab_clt = stk_avant_fab_clt - conso_possible_clt ' ici on va soustraire du stock dispo avant fab clt la conso du clt par pas de calcul
stk_vide_clt = stk_vide_clt + conso_possible_clt ' notre stock vide clt serait notre conso par pas de calcul
Else
manque_plein_clt = bac_convoi_clt - stk_avant_fab_clt
End If
End If
End If

'Avancement des fr?quences transport clt
'Condition : temps de transport < fr?quence de transport



If etat_trans_clt <> 0 Then
If etat_trans_clt >= tps_trans_clt Then
etat_trans_clt = 0
stk_vide_fnr = stk_vide_fnr + stk_trans_clt
stk_trans_clt = 0
Else
etat_trans_clt = etat_trans_clt + pas 'A ANALYSER ON DOIT PAS AVOIR 1 CAR LA CONDITION ETAIT QUE LE COMPTEUR SE MET A 0

End If
Else
If stk_trans_clt <> 0 Then
etat_trans_clt = etat_trans_clt + pas
End If
End If



If etat_freq_trans_clt <> 0 Then
If etat_freq_trans_clt >= freq_trans_clt Then
etat_freq_trans_clt = 0 ' ici la condition pour mettre le compteur ? 0
stk_trans_clt = stk_vide_clt 'le stock tpt clt prend la totalit? du stock vide clt
stk_vide_clt = 0 'le stock vide diminue
Else
etat_freq_trans_clt = etat_freq_trans_clt + pas '
End If
Else
etat_freq_trans_clt = etat_freq_trans_clt + pas ' on repasse de 0 ? 0.5
End If
'double controle pour remttre le compteur ? 0

If etat_freq_trans_clt <> 0 Then
If etat_freq_trans_clt >= freq_trans_clt Then
etat_freq_trans_clt = 0 ' ici la condition pour mettre le compteur ? 0
stk_trans_clt = stk_vide_clt 'le stock tpt clt prend la totalit? du stock vide clt
stk_vide_clt = 0 'le stock vide diminue
End If
End If








Sheets(2).Range("B4") = stk_vide_fnr 'Nbr de bacs
Sheets(2).Range("C4") = etat_stk_vide_fnr 'Temps d'attente ?coul? des bacs vides avant mise ? dispo fabrication
Sheets(2).Range("D4") = stk_vide_fab_fnr 'Nbr de bacs dispos pour la fabrication
Sheets(2).Range("D5") = manque_vide_fnr
Sheets(2).Range("E4") = etat_convoi_fnr 'Avancement de la fabrication pour le Fnr
Sheets(2).Range("F4") = stk_ec_fnr
Sheets(2).Range("G4") = stk_secu_fnr
Sheets(2).Range("H4") = etat_delai_avant_rpt_fnr
Sheets(2).Range("I4") = stk_plein_fnr
Sheets(2).Range("J4") = etat_freq_trans_fnr
Sheets(2).Range("K4") = stk_trans_fnr
Sheets(2).Range("L8") = etat_trans_fnr
Sheets(2).Range("K14") = stk_secu_clt
Sheets(2).Range("J14") = stk_plein_clt
Sheets(2).Range("I14") = etat_stk_plein_clt
Sheets(2).Range("H14") = stk_avant_fab_clt
Sheets(2).Range("H13") = manque_plein_clt
Sheets(2).Range("F14") = etat_convoi_clt
Sheets(2).Range("D14") = stk_vide_clt
Sheets(2).Range("C14") = etat_freq_trans_clt
Sheets(2).Range("B14") = stk_trans_clt
Sheets(2).Range("A8") = etat_trans_clt
Sheets(2).Range("E8") = i
'?criture donn?es sur feuille
Sheets(3).Cells(j, 1) = i
Sheets(3).Cells(j, 2) = stk_vide_fnr
Sheets(3).Cells(j, 3) = etat_stk_vide_fnr
Sheets(3).Cells(j, 4) = stk_vide_fab_fnr
Sheets(3).Cells(j, 5) = etat_convoi_fnr
Sheets(3).Cells(j, 6) = stk_ec_fnr
Sheets(3).Cells(j, 7) = stk_secu_fnr
Sheets(3).Cells(j, 8) = etat_delai_avant_rpt_fnr
Sheets(3).Cells(j, 9) = stk_plein_fnr
Sheets(3).Cells(j, 10) = etat_freq_trans_fnr
Sheets(3).Cells(j, 11) = stk_trans_fnr
Sheets(3).Cells(j, 12) = etat_trans_fnr
Sheets(3).Cells(j, 13) = stk_secu_clt
Sheets(3).Cells(j, 14) = stk_plein_clt
Sheets(3).Cells(j, 15) = etat_delai_avant_fab_clt
Sheets(3).Cells(j, 16) = stk_avant_fab_clt
Sheets(3).Cells(j, 17) = etat_convoi_clt
Sheets(3).Cells(j, 18) = stk_vide_clt
Sheets(3).Cells(j, 19) = etat_freq_trans_clt
Sheets(3).Cells(j, 20) = stk_trans_clt
Sheets(3).Cells(j, 21) = etat_trans_clt
Sheets(3).Cells(j, 22) = manque_vide_fnr
Sheets(3).Cells(j, 23) = manque_plein_clt
Sheets(3).Cells(j, 24) = flag_fnr
Sheets(3).Cells(j, 25) = flag_clt

If flag = 0 Then
stk_vide_fnr = 0
Sheets(2).Range("B4") = stk_vide_fnr
Sheets(3).Cells(j, 2) = stk_vide_fnr
etat_convoi_fnr = etat_convoi_fnr + pas
End If
If stk_vide_fnr <> 0 Then
etat_stk_vide_fnr = etat_stk_vide_fnr + pas
End If
If stk_vide_fab_fnr <> 0 Then
If flag = 1 Then
etat_convoi_fnr = etat_convoi_fnr + pas
If etat_convoi_fnr > convoi_fnr Then
etat_convoi_fnr = etat_convoi_fnr - convoi_fnr
End If
End If
End If
If stk_plein_clt <> 0 Then
etat_stk_plein_clt = etat_stk_plein_clt + pas
End If

If stk_avant_fab_clt <> 0 Then ' ON DECLENCHE LE COMPTEUR SI LE STOCK AV DISPO CLT > 0
etat_convoi_clt = etat_convoi_clt + pas ' LE COMPTEUR PASSE DE 0 A 0.5
If etat_convoi_clt >= convoi_clt Then
etat_convoi_clt = etat_convoi_clt - convoi_clt ' ??? LE COMPTEUR PASSE BIEN DE 0 A 0.5 DE 0.5 A 1 MAIS LA CONSO NE CHANGE PAS????
End If ' etat convoi clt passe ? 0
End If
If etat_convoi_clt <> 0 Then ' a effacer si marche pas
If etat_convoi_clt > convoi_clt Then
etat_convoi_clt = etat_convoi_clt - convoi_clt ' ??????
End If
If etat_convoi_clt <= tps_prod_clt + pas - 0.000001 Then
If stk_avant_fab_clt < (bac_convoi_clt * (tps_prod_clt - etat_convoi_clt)) Then
conso_possible4 = 0
manque_plein_clt = bac_convoi_clt - stk_avant_fab_clt ' ???
flag_clt = 1
Else
conso_possible4 = nb_um_jour * pas_fab_clt
End If
If etat_convoi_clt <= pas Then
If stk_avant_fab_clt < bac_convoi_clt Then
conso_possible5 = 0 ' il met une consommation de 0 si le bac convoi clt est > stock avant fab clt
manque_plein_clt = bac_convoi_clt - stk_avant_fab_clt
flag_clt = 1
Else
conso_possible5 = bac_convoi_clt * etat_convoi_clt
End If
Else
conso_possible5 = nb_um_jour * pas_fab_clt
End If
If etat_convoi_clt > tps_prod_clt Then
conso_possible6 = bac_convoi_clt * WorksheetFunction.Min(pas, pas - etat_convoi_clt + tps_prod_clt) '?????
Else
conso_possible6 = nb_um_jour * pas_fab_clt
End If
conso_possible_clt = WorksheetFunction.Min(conso_possible4, conso_possible5, conso_possible6)

If stk_avant_fab_clt >= bac_convoi_clt * (tps_prod_clt - etat_convoi_clt) Then
stk_avant_fab_clt = stk_avant_fab_clt - conso_possible_clt ' ici on va soustraire du stock dispo avant fab clt la conso du clt par pas de calcul
stk_vide_clt = stk_vide_clt + conso_possible_clt ' notre stock vide clt serait notre conso par pas de calcul
Else
manque_plein_clt = bac_convoi_clt - stk_avant_fab_clt
End If
End If
End If

If flag = 0 Then
flag = 1
End If
'incr?mentation
i = i - 1
i = i + pas
j = j + 1

Next i

Sheets(4).Activate
End Sub
Re

SKN-44
Utilises les balises BBCODE pour formater le code VBA dans le message
(voir explications dans ma signature)
Salut je suis débutant dans les macros le terme bb code me semble inconnu
 

Staple1600

XLDnaute Barbatruc
Re

Comme je le disais, il suffisait de lire ma signature (en rouge en bas de mes messages)
Donc exemple ci-dessous
• sans balisage BBCODE
Sub Macro1()
Dim Ligne As Long
Ligne=Cells(1).Row
MsgBox Ligne, 64
End Sub
• avec balisage BBCODE
VB:
Sub Macro1()
Dim Ligne As Long
Ligne=Cells(1).Row
MsgBox Ligne, 64
End Sub
 

Discussions similaires

Réponses
2
Affichages
193