Il a quelques jours j'ai fait une macro qui marche très bien grâce aux experts de ce forum. Je me suis lancé sur une autre macro similaire mais elle ne marche pas, j'obtiens une erreur: "Run time error 13".
SVP, pouvez-vous me donner un coup de main?
Private Sub CheckBox1_Click()
If CheckBox1.Value = True Then CheckBox2.Value = False
If CheckBox1.Value = True Then [G7] = "Glutamic acid (g/Kg) in FP"
If CheckBox1.Value = True Then [E7] = "REGULATION (EC) No 1333/2008: Group I"
If Not CheckBox1 Then [E7:H9].ClearContents: Exit Sub
If IsNumeric([E3:E5]) And [E3] <> 0 Then [E8] = Application.Sum([D3:D5]) * [H6] * 10
If [E3:E5] = "" Then [E9] = Application.Sum([D3:D5]) * ([J9] / 100) * 10
Private Sub CheckBox1_Click()
Set sh = Sheets("Feuil3") 'à adapter
If CheckBox1.Value = True Then
sh.[G7] = "Glutamic acid (g/Kg) in FP"
sh.[E7] = "REGULATION (EC) No 1333/2008: Group I"
CheckBox2.Value = False
Else
sh.[E7:H9].ClearContents: Exit Sub
End If
For Each c In sh.[E3:E5]
If IsNumeric(c) And c <> 0 Then x = 1 Else x = 0
Next
If x = 1 Then
sh.[E8] = Application.Sum(sh.[D3:D5]) * sh.[H6] * 10: x = 0
sh.[E9] = Application.Sum(sh.[D3:D5]) * (sh.[J9] / 100) * 10
End If
End Sub
Private Sub CheckBox1_Click()
With Sheets("Phosphates Calculator")
If Not CheckBox1 Then [E13:M15].ClearContents: Exit Sub
CheckBox2 = 0: CheckBox5 = 0: [G13] = "P2O5 (mg/Kg) in FP"
[E13] = "REGULATION (EC) No 1333/2008: 08.3.1 Non-heat-treated " _
& "meat products & 08.3.2 Heat-treated meat products"
If [E9] <> 0 Then [E14] = Application.Sum([D12] * [H12] * 10000)
[G14] = IIf([E14] > 5000, "NO", "YES")
If [E9] <> 0 Then [E15] = Application.Sum([D12] * ([J9] / 100) * 10000)
End With
End Sub
Private Sub CheckBox2_Click()
If CheckBox2 Then
CheckBox1 = 0: CheckBox5 = 0
CheckBox3.Visible = -1: CheckBox4.Visible = -1
Else
CheckBox3.Visible = 0: CheckBox4.Visible = 0
End If
End Sub
Private Sub CheckBox3_Click()
If Not CheckBox3 Then [E13:M15].ClearContents: Exit Sub
CheckBox4 = 0: [G13] = "P (mg/Kg) in FP"
[E13] = "08.2.1 Non-heat treated processed meat, poultry, " _
& "and game products in whole pieces or cuts"
If [E9] <> 0 Then [E14] = Application.Sum([D12] * [H12] * 10000 * 0.4364)
[G14] = IIf([E14] > 2200, "NO", "YES")
If [E9] <> 0 Then [E15] = Application.Sum([D12] * ([J9] / 100) * 10000 * 0.4364)
End Sub
Private Sub CheckBox4_Click()
If Not CheckBox4 Then [E13:M15].ClearContents: Exit Sub
CheckBox3 = 0: [G13] = "P (mg/Kg) in FP"
[E13] = "08.2.2 Heat treated processed meat, poultry, " _
& "and game products in whole pieces or cuts"
If [E9] <> 0 Then [E14] = Application.Sum([D12] * [H12] * 10000 * 0.4364)
[G14] = IIf([E14] > 1320, "NO", "YES")
If [E9] <> 0 Then [E15] = Application.Sum([D12] * ([J9] / 100) * 10000 * 0.4364)
End Sub
Private Sub CheckBox5_Click()
If Not CheckBox5 Then [E13:M15].ClearContents: Exit Sub
CheckBox1 = 0: CheckBox2 = 0: CheckBox4 = 0: [G13] = "P2O5 (g/Kg) in FP"
[E13] = "TR CU 029/2012: Meat products, except for " _
& "non-processed products and meat filling"
If [E9] <> 0 Then [E14] = Application.Sum([D12] * [H12])
[G14] = IIf([E14] > 3, "NO", "YES")
If [E9] <> 0 Then [E15] = Application.Sum([D12] * ([J9] / 100))
End Sub
J’avais écris le mot de passe dans le commentaire mais j’ai oublié d’écrire « mdp: ». Le mdp c’est lilette.
Bonjour André,
La 1ère feuille marche bien. C’est la 2ème feuille dont j’avais des problèmes d’erreur mais Isabelle a résolu l’erreur sauf que les résultats ne s’affichent pas.
J'ai fais deux/trois modifications au UserForm2 et rajouté "[G14] = IIf([E14] > 5000 Or [E15] > 5000, "NO", "YES")" dans UserForm1 (j'ai vu que tu l'as fait ça dans UserForm2 et c'est ça qui me manquait pour cloturer UserForm1). Merci
Si je rempli les celulles D3 et/ou D4 et/ou D5 et ensuite les celulles D3 à H5, et choisi par la suite "Glutamic acid" ou "Guanylic acid", j'obtiens bien les résultats dans E8 et G8. Cette parti marche très bien Merci!
Si je rempli les celulles D3 et/ou D4 et/ou D5 et ensuite la celulle J3, et choisi par la suite "Glutamic acid" ou "Guanylic acid", je n'obtiens pas les résultats dans E9 et G8. Tout semble ok donc je ne vois pas pourquoi est-ce qu'il n'y pas de résultat.
STP, n'hésites pas à me dire si ce n'est pas clair et je vais re formuler l'explication ci-dessous.
Grace à l'explication que tu m'as donné j'ai pu comprendre à quoi sert l'astuce que tu avais fait. J'ai fait un mini adaptation et tout marche super bien.