13 OptionButton, code complètement perdu

N

Nanard

Guest
Bonsoir le forum,

Voici mon problème :

J'ai 13 optionButton que j'utilise dand un USF
Avec un commandButton1, je valide l'opération en cliquant
Quelquefois les informations renvoyées sont justes, d'autres fois les informations renvoyées sont des zéros ou rien !!!!

Je n'y comprend plus rien merci pour l'aide

Mon code est un peu long mais le voici :

Private Sub CommandButton1_Click()
'Bouton 8 Distance
If OptionButton8.Value = True And OptionButton1.Value = True Then
Sheets("Distance").Range("A13").Value = TextBox1.Value
Range("A13:J13").Select
Selection.NumberFormat = "0.00"
TextBox2.Value = Range("C13").Value
TextBox3.Value = Range("D13").Value
TextBox4.Value = Range("E13").Value
TextBox5.Value = Range("F13").Value
TextBox6.Value = Range("G13").Value
TextBox7.Value = Range("H13").Value
TextBox8.Value = Range("I13").Value
TextBox9.Value = Range("J13").Value
TextBox1.SetFocus
End If
If OptionButton8.Value = True And OptionButton2.Value = True Then
Sheets("Distance").Range("A12").Value = TextBox1.Value
TextBox2.Value = Range("C12").Value
TextBox3.Value = Range("D12").Value
TextBox4.Value = Range("E12").Value
TextBox5.Value = Range("F12").Value
TextBox6.Value = Range("G12").Value
TextBox7.Value = Range("H12").Value
TextBox8.Value = Range("I12").Value
TextBox9.Value = Range("J13").Value
TextBox1.SetFocus
End If
If OptionButton8.Value = True And OptionButton3.Value = True Then
Sheets("Distance").Range("A11").Value = TextBox1.Value
TextBox2.Value = Range("C11").Value
TextBox3.Value = Range("D11").Value
TextBox4.Value = Range("E11").Value
TextBox5.Value = Range("F11").Value
TextBox6.Value = Range("G11").Value
TextBox7.Value = Range("H11").Value
TextBox8.Value = Range("I11").Value
TextBox9.Value = Range("J13").Value
TextBox1.SetFocus
End If
If OptionButton8.Value = True And OptionButton4.Value = True Then
Sheets("Distance").Range("A10").Value = TextBox1.Value
TextBox2.Value = Range("C10").Value
TextBox3.Value = Range("D10").Value
TextBox4.Value = Range("E10").Value
TextBox5.Value = Range("F10").Value
TextBox6.Value = Range("G10").Value
TextBox7.Value = Range("H10").Value
TextBox8.Value = Range("I10").Value
TextBox9.Value = Range("J13").Value
TextBox1.SetFocus
End If
If OptionButton8.Value = True And OptionButton5.Value = True Then
Sheets("Distance").Range("A9").Value = TextBox1.Value
TextBox2.Value = Range("C9").Value
TextBox3.Value = Range("D9").Value
TextBox4.Value = Range("E9").Value
TextBox5.Value = Range("F9").Value
TextBox6.Value = Range("G9").Value
TextBox7.Value = Range("H9").Value
TextBox8.Value = Range("I9").Value
TextBox9.Value = Range("J13").Value
TextBox1.SetFocus
End If
If OptionButton8.Value = True And OptionButton6.Value = True Then
Sheets("Distance").Range("A8").Value = TextBox1.Value
TextBox2.Value = Range("C8").Value
TextBox3.Value = Range("D8").Value
TextBox4.Value = Range("E8").Value
TextBox5.Value = Range("F8").Value
TextBox6.Value = Range("G8").Value
TextBox7.Value = Range("H8").Value
TextBox8.Value = Range("I8").Value
TextBox9.Value = Range("J13").Value
TextBox1.SetFocus
End If
If OptionButton8.Value = True And OptionButton7.Value = True Then
Sheets("Distance").Range("A7").Value = TextBox1.Value
TextBox2.Value = Range("C7").Value
TextBox3.Value = Range("D7").Value
TextBox4.Value = Range("E7").Value
TextBox5.Value = Range("F7").Value
TextBox6.Value = Range("G7").Value
TextBox7.Value = Range("H7").Value
TextBox8.Value = Range("I7").Value
TextBox9.Value = Range("J13").Value
TextBox1.SetFocus
End If
'<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
'Bouton 9 Contenance
If OptionButton9.Value = True And OptionButton1.Value = True Then
Sheets("Contenance").Range("A13").Value = TextBox1.Value
Range("A13:H13").Select
Selection.NumberFormat = "0.00"
TextBox2.Value = Range("C13").Value
TextBox3.Value = Range("D13").Value
TextBox4.Value = Range("E13").Value
TextBox5.Value = Range("F13").Value
TextBox6.Value = Range("G13").Value
TextBox7.Value = Range("H13").Value
TextBox1.SetFocus
End If
If OptionButton9.Value = True And OptionButton2.Value = True Then
Sheets("Contenance").Range("A12").Value = TextBox1.Value
TextBox2.Value = Range("C12").Value
TextBox3.Value = Range("D12").Value
TextBox4.Value = Range("E12").Value
TextBox5.Value = Range("F12").Value
TextBox6.Value = Range("G12").Value
TextBox7.Value = Range("H12").Value
TextBox1.SetFocus
End If
If OptionButton9.Value = True And OptionButton3.Value = True Then
Sheets("Contenance").Range("A11").Value = TextBox1.Value
TextBox2.Value = Range("C11").Value
TextBox3.Value = Range("D11").Value
TextBox4.Value = Range("E11").Value
TextBox5.Value = Range("F11").Value
TextBox6.Value = Range("G11").Value
TextBox7.Value = Range("H11").Value
TextBox1.SetFocus
End If
If OptionButton9.Value = True And OptionButton4.Value = True Then
Sheets("Contenance").Range("A10").Value = TextBox1.Value
TextBox2.Value = Range("C10").Value
TextBox3.Value = Range("D10").Value
TextBox4.Value = Range("E10").Value
TextBox5.Value = Range("F10").Value
TextBox6.Value = Range("G10").Value
TextBox7.Value = Range("H10").Value
TextBox1.SetFocus
End If
If OptionButton9.Value = True And OptionButton5.Value = True Then
Sheets("Contenance").Range("A9").Value = TextBox1.Value
TextBox2.Value = Range("C9").Value
TextBox3.Value = Range("D9").Value
TextBox4.Value = Range("E9").Value
TextBox5.Value = Range("F9").Value
TextBox6.Value = Range("G9").Value
TextBox7.Value = Range("H9").Value
TextBox1.SetFocus
End If
If OptionButton9.Value = True And OptionButton6.Value = True Then
Sheets("Contenance").Range("A8").Value = TextBox1.Value
TextBox2.Value = Range("C8").Value
TextBox3.Value = Range("D8").Value
TextBox4.Value = Range("E8").Value
TextBox5.Value = Range("F8").Value
TextBox6.Value = Range("G8").Value
TextBox7.Value = Range("H8").Value
TextBox1.SetFocus
End If
'<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
If OptionButton10.Value = True And OptionButton1.Value = True Then
Sheets("Poids").Range("A15").Value = TextBox1.Value
Range("A15:K15").Select
Selection.NumberFormat = "0.00"
TextBox2.Value = Range("C15").Value
TextBox3.Value = Range("D15").Value
TextBox4.Value = Range("E15").Value
TextBox5.Value = Range("F15").Value
TextBox6.Value = Range("G15").Value
TextBox7.Value = Range("H15").Value
TextBox8.Value = Range("I15").Value
TextBox9.Value = Range("J15").Value
TextBox10.Value = Range("K15").Value
TextBox1.SetFocus
End If
If OptionButton10.Value = True And OptionButton2.Value = True Then
Sheets("Poids").Range("A14").Value = TextBox1.Value
TextBox2.Value = Range("C14").Value
TextBox3.Value = Range("D14").Value
TextBox4.Value = Range("E14").Value
TextBox5.Value = Range("F14").Value
TextBox6.Value = Range("G14").Value
TextBox7.Value = Range("H14").Value
TextBox8.Value = Range("I14").Value
TextBox9.Value = Range("J14").Value
TextBox10.Value = Range("K14").Value
TextBox1.SetFocus
End If
If OptionButton10.Value = True And OptionButton3.Value = True Then
Sheets("Poids").Range("A13").Value = TextBox1.Value
TextBox2.Value = Range("C13").Value
TextBox3.Value = Range("D13").Value
TextBox4.Value = Range("E13").Value
TextBox5.Value = Range("F13").Value
TextBox6.Value = Range("G13").Value
TextBox7.Value = Range("H13").Value
TextBox8.Value = Range("I13").Value
TextBox9.Value = Range("J13").Value
TextBox10.Value = Range("K13").Value
TextBox1.SetFocus
End If
If OptionButton10.Value = True And OptionButton4.Value = True Then
Sheets("Poids").Range("A12").Value = TextBox1.Value
TextBox2.Value = Range("C12").Value
TextBox3.Value = Range("D12").Value
TextBox4.Value = Range("E12").Value
TextBox5.Value = Range("F12").Value
TextBox6.Value = Range("G12").Value
TextBox7.Value = Range("H12").Value
TextBox8.Value = Range("I12").Value
TextBox9.Value = Range("J12").Value
TextBox10.Value = Range("K12").Value
TextBox1.SetFocus
End If
If OptionButton10.Value = True And OptionButton5.Value = True Then
Sheets("Poids").Range("A11").Value = TextBox1.Value
TextBox2.Value = Range("C11").Value
TextBox3.Value = Range("D11").Value
TextBox4.Value = Range("E11").Value
TextBox5.Value = Range("F11").Value
TextBox6.Value = Range("G11").Value
TextBox7.Value = Range("H11").Value
TextBox8.Value = Range("I11").Value
TextBox9.Value = Range("J11").Value
TextBox10.Value = Range("K11").Value
TextBox1.SetFocus
End If
If OptionButton10.Value = True And OptionButton6.Value = True Then
Sheets("Poids").Range("A10").Value = TextBox1.Value
TextBox2.Value = Range("C10").Value
TextBox3.Value = Range("D10").Value
TextBox4.Value = Range("E10").Value
TextBox5.Value = Range("F10").Value
TextBox6.Value = Range("G10").Value
TextBox7.Value = Range("H10").Value
TextBox8.Value = Range("I10").Value
TextBox9.Value = Range("J10").Value
TextBox10.Value = Range("K10").Value
TextBox1.SetFocus
End If
If OptionButton10.Value = True And OptionButton7.Value = True Then
Sheets("Poids").Range("A9").Value = TextBox1.Value
TextBox2.Value = Range("C9").Value
TextBox3.Value = Range("D9").Value
TextBox4.Value = Range("E9").Value
TextBox5.Value = Range("F9").Value
TextBox6.Value = Range("G9").Value
TextBox7.Value = Range("H9").Value
TextBox8.Value = Range("I9").Value
TextBox9.Value = Range("J9").Value
TextBox10.Value = Range("K9").Value
TextBox1.SetFocus
End If
If OptionButton10.Value = True And OptionButton8.Value = True Then
Sheets("Poids").Range("A8").Value = TextBox1.Value
TextBox2.Value = Range("C8").Value
TextBox3.Value = Range("D8").Value
TextBox4.Value = Range("E8").Value
TextBox5.Value = Range("F8").Value
TextBox6.Value = Range("G8").Value
TextBox7.Value = Range("H8").Value
TextBox8.Value = Range("I8").Value
TextBox9.Value = Range("J8").Value
TextBox10.Value = Range("K8").Value
TextBox1.SetFocus
End If
If OptionButton10.Value = True And OptionButton9.Value = True Then
Sheets("Poids").Range("A7").Value = TextBox1.Value
TextBox2.Value = Range("C7").Value
TextBox3.Value = Range("D7").Value
TextBox4.Value = Range("E7").Value
TextBox5.Value = Range("F7").Value
TextBox6.Value = Range("G7").Value
TextBox7.Value = Range("H7").Value
TextBox8.Value = Range("I7").Value
TextBox9.Value = Range("J7").Value
TextBox10.Value = Range("K7").Value
TextBox1.SetFocus
End If
'<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
If OptionButton11.Value = True And OptionButton1.Value = True Then
Sheets("Aire").Range("A13").Value = TextBox1.Value
Range("A13:H13").Activate
Selection.NumberFormat = "0.00"
TextBox2.Value = Range("C13").Value
TextBox3.Value = Range("D13").Value
TextBox4.Value = Range("E13").Value
TextBox5.Value = Range("F13").Value
TextBox6.Value = Range("G13").Value
TextBox7.Value = Range("H13").Value
TextBox1.SetFocus
End If
If OptionButton11.Value = True And OptionButton2.Value = True Then
Sheets("Aire").Range("A12").Value = TextBox1.Value
TextBox2.Value = Range("C12").Value
TextBox3.Value = Range("D12").Value
TextBox4.Value = Range("E12").Value
TextBox5.Value = Range("F12").Value
TextBox6.Value = Range("G12").Value
TextBox7.Value = Range("H12").Value
TextBox1.SetFocus
End If
If OptionButton11.Value = True And OptionButton3.Value = True Then
Sheets("Aire").Range("A11").Value = TextBox1.Value
TextBox2.Value = Range("C11").Value
TextBox3.Value = Range("D11").Value
TextBox4.Value = Range("E11").Value
TextBox5.Value = Range("F11").Value
TextBox6.Value = Range("G11").Value
TextBox7.Value = Range("H11").Value
TextBox1.SetFocus
End If
If OptionButton11.Value = True And OptionButton4.Value = True Then
Sheets("Aire").Range("A10").Value = TextBox1.Value
TextBox2.Value = Range("C10").Value
TextBox3.Value = Range("D10").Value
TextBox4.Value = Range("E10").Value
TextBox5.Value = Range("F10").Value
TextBox6.Value = Range("G10").Value
TextBox7.Value = Range("H10").Value
TextBox1.SetFocus
End If
If OptionButton11.Value = True And OptionButton5.Value = True Then
Sheets("Aire").Range("A9").Value = TextBox1.Value
TextBox2.Value = Range("C9").Value
TextBox3.Value = Range("D9").Value
TextBox4.Value = Range("E9").Value
TextBox5.Value = Range("F9").Value
TextBox6.Value = Range("G9").Value
TextBox7.Value = Range("H9").Value
TextBox1.SetFocus
End If
If OptionButton11.Value = True And OptionButton6.Value = True Then
Sheets("Aire").Range("A8").Value = TextBox1.Value
TextBox2.Value = Range("C8").Value
TextBox3.Value = Range("D8").Value
TextBox4.Value = Range("E8").Value
TextBox5.Value = Range("F8").Value
TextBox6.Value = Range("G8").Value
TextBox7.Value = Range("H8").Value
TextBox1.SetFocus
End If
End Sub

faut'il déclarer des variables à partir de OptionButton ? et comment ?

Merci encore pour l'aide

@+
Nanard
 
N

Nanard

Guest
Rererenanard, RerereBonsoir le forum,

Merci pour ta réponse Nanard

Il y avait diverses petites erreurs dand ton code que j'ai corrigé , maintenant ça devrait aller ! lol

Bon aller je ne suis pas un grand expert dans la composition d'un code, mais ça marche ...

Si quelqu'un à une idée pour faire + court

@+

Nanard
 
M

myDearFriend

Guest
Bonsoir Nanard,

D'abord, bravo pour ton humour.

Ensuite, si tu as la possibilité de joindre ton fichier ici (Zip de 50 Ko maxi), je pense qu'on serait plus à même de t'aider car vu comme ça, ton code n'est pas très causant.

Cordialement.

Didier_mDF
myDearFriend-3.gif
 
N

Nanard

Guest
Bonsoir MyDearFriend,

Merci pour ton aide mais tout fonctionne normalement


J'ai seulement passé trop de temps "dessus" hier de 9h00 à 24h00 et à vrai dire je ne comprenais plus rien ! lol

Je te le joint par mail, il s'agit d'un USF qui convertit nombre de choses : distance, aire, poids, surface...etc

le etc c'est pour ce qui va s'y ajouter...!

Merci encore pour ton aide


@+

Nanard
 

Discussions similaires

Statistiques des forums

Discussions
311 725
Messages
2 081 940
Membres
101 845
dernier inscrit
annesof