Code pour fermeture Userform1
Bonjour a tous,
Peux ton me donner le code pour fermer mon Userform1 après validation.
Merci.
Mon code:
Private Sub CommandButton1_Click()
Dim DERLIGNE As Long
DERLIGNE = Worksheets("Tableau").Range("B65536").End(xlUp).Row + 1
' Ensuite on utilise DERLIGNE comme numéro de ligne pour valider
Sheets("Tableau").Range("C" & DERLIGNE) = TextBox2.Value
Sheets("Tableau").Range("B" & DERLIGNE) = TextBox4.Value
'Type de vente
'VN
If OptionButton11.Value = True Then
Sheets("Tableau").Range("D" & DERLIGNE) = OptionButton11.Caption
End If
' VD
If OptionButton12.Value = True Then
Sheets("Tableau").Range("D" & DERLIGNE) = OptionButton12.Caption
End If
If OptionButton12.Value = True Then
Sheets("Tableau").Range("F" & DERLIGNE) = CDbl(TextBox7.Value * 0.006)
End If
' VO
If OptionButton13.Value = True Then
Sheets("Tableau").Range("D" & DERLIGNE) = OptionButton13.Caption
End If
If OptionButton13.Value = True Then
Sheets("Tableau").Range("F" & DERLIGNE) = CDbl(TextBox7.Value * 0.006)
End If
'Modèle DS3
If OptionButton3.Value = True Then
Sheets("Tableau").Range("E" & DERLIGNE) = OptionButton3.Caption
End If
If OptionButton22.Value = True And OptionButton3.Value = True And OptionButton11.Value = True Then
Sheets("Tableau").Range("F" & DERLIGNE) = 50
End If
If OptionButton23.Value = True And OptionButton3.Value = True And OptionButton11.Value = True Then
Sheets("Tableau").Range("F" & DERLIGNE) = 100
End If
'Modèle DS4
If OptionButton1.Value = True Then
Sheets("Tableau").Range("E" & DERLIGNE) = OptionButton1.Caption
End If
If OptionButton22.Value = True And OptionButton1.Value = True And OptionButton11.Value = True Then
Sheets("Tableau").Range("F" & DERLIGNE) = 60
End If
If OptionButton23.Value = True And OptionButton1.Value = True And OptionButton11.Value = True Then
Sheets("Tableau").Range("F" & DERLIGNE) = 120
End If
'Modèle DS7
If OptionButton4.Value = True Then
Sheets("Tableau").Range("E" & DERLIGNE) = OptionButton4.Caption
End If
If OptionButton22.Value = True And OptionButton4.Value = True And OptionButton11.Value = True Then
Sheets("Tableau").Range("F" & DERLIGNE) = 70
End If
If OptionButton23.Value = True And OptionButton4.Value = True And OptionButton11.Value = True Then
Sheets("Tableau").Range("F" & DERLIGNE) = 140
End If
'Modèle DS9
If OptionButton2.Value = True Then
Sheets("Tableau").Range("E" & DERLIGNE) = OptionButton2.Caption
End If
If OptionButton22.Value = True And OptionButton2.Value = True And OptionButton11.Value = True Then
Sheets("Tableau").Range("F" & DERLIGNE) = 100
End If
If OptionButton23.Value = True And OptionButton2.Value = True And OptionButton11.Value = True Then
Sheets("Tableau").Range("F" & DERLIGNE) = 200
End If
'Modèle Hybride
If OptionButton5.Value = True Then
Sheets("Tableau").Range("E" & DERLIGNE) = OptionButton5.Caption
End If
If OptionButton22.Value = True And OptionButton5.Value = True And OptionButton11.Value = True Then
Sheets("Tableau").Range("F" & DERLIGNE) = 100
End If
If OptionButton23.Value = True And OptionButton5.Value = True And OptionButton11.Value = True Then
Sheets("Tableau").Range("F" & DERLIGNE) = 200
End If
'Modèle Electique
If OptionButton6.Value = True Then
Sheets("Tableau").Range("E" & DERLIGNE) = OptionButton6.Caption
End If
If OptionButton22.Value = True And OptionButton6.Value = True And OptionButton11.Value = True Then
Sheets("Tableau").Range("F" & DERLIGNE) = 150
End If
If OptionButton23.Value = True And OptionButton6.Value = True And OptionButton11.Value = True Then
Sheets("Tableau").Range("F" & DERLIGNE) = 250
End If
'Fmr 1
If OptionButton7.Value = True Then
Sheets("Tableau").Range("G" & DERLIGNE) = OptionButton7.Caption
Sheets("Tableau").Range("H" & DERLIGNE) = 20
End If
' Fmr 2
If OptionButton9.Value = True Then
Sheets("Tableau").Range("G" & DERLIGNE) = OptionButton9.Caption
Sheets("Tableau").Range("H" & DERLIGNE) = 55
End If
'Fmr 3
If OptionButton8.Value = True Then
Sheets("Tableau").Range("G" & DERLIGNE) = OptionButton8.Caption
Sheets("Tableau").Range("H" & DERLIGNE) = 75
End If
'Fmr Vo
If OptionButton10.Value = True Then
Sheets("Tableau").Range("G" & DERLIGNE) = OptionButton10.Caption
Sheets("Tableau").Range("H" & DERLIGNE) = 30
End If
' Financement
' Comptant
If OptionButton18.Value = True Then
Sheets("Tableau").Range("i" & DERLIGNE) = OptionButton18.Caption
Sheets("Tableau").Range("J" & DERLIGNE) = 0
End If
'LLD
If OptionButton19.Value = True Then
Sheets("Tableau").Range("I" & DERLIGNE) = OptionButton19.Caption
Sheets("Tableau").Range("J" & DERLIGNE) = CDbl(TextBox3.Value - TextBox5.Value - TextBox6.Value) / 1.2
End If
'LOA
If OptionButton20.Value = True Then
Sheets("Tableau").Range("I" & DERLIGNE) = OptionButton20.Caption
Sheets("Tableau").Range("J" & DERLIGNE) = CDbl(TextBox3.Value - TextBox5.Value) / 1.2
End If
'Credit
If OptionButton21.Value = True Then
Sheets("Tableau").Range("I" & DERLIGNE) = OptionButton21.Caption
Sheets("Tableau").Range("J" & DERLIGNE) = CDbl(TextBox3.Value - TextBox5.Value)
End If
'Contrat de service
' Extention de garantie
If OptionButton14.Value = True Then
Sheets("Tableau").Range("k" & DERLIGNE) = OptionButton14.Caption
End If
If OptionButton18.Value = True And OptionButton14.Value = True Then
Sheets("Tableau").Range("L" & DERLIGNE) = 0
End If
If OptionButton19.Value = True And OptionButton14.Value = True Then
Sheets("Tableau").Range("L" & DERLIGNE) = 0
End If
If OptionButton20.Value = True And OptionButton14.Value = True Then
Sheets("Tableau").Range("L" & DERLIGNE) = 0
End If
If OptionButton21.Value = True And OptionButton14.Value = True Then
Sheets("Tableau").Range("L" & DERLIGNE) = 0
End If
' Extention de garantie et entretien
If OptionButton15.Value = True Then
Sheets("Tableau").Range("k" & DERLIGNE) = OptionButton15.Caption
End If
If OptionButton18.Value = True And OptionButton15.Value = True Then
Sheets("Tableau").Range("L" & DERLIGNE) = 20
End If
If OptionButton19.Value = True And OptionButton15.Value = True Then
Sheets("Tableau").Range("L" & DERLIGNE) = 40
End If
If OptionButton20.Value = True And OptionButton15.Value = True Then
Sheets("Tableau").Range("L" & DERLIGNE) = 40
End If
If OptionButton21.Value = True And OptionButton15.Value = True Then
Sheets("Tableau").Range("L" & DERLIGNE) = 40
End If
' Freedrive
If OptionButton16.Value = True Then
Sheets("Tableau").Range("k" & DERLIGNE) = OptionButton16.Caption
End If
If OptionButton18.Value = True And OptionButton16.Value = True Then
Sheets("Tableau").Range("L" & DERLIGNE) = 20
End If
If OptionButton19.Value = True And OptionButton16.Value = True Then
Sheets("Tableau").Range("L" & DERLIGNE) = 40
End If
If OptionButton20.Value = True And OptionButton16.Value = True Then
Sheets("Tableau").Range("L" & DERLIGNE) = 40
End If
If OptionButton21.Value = True And OptionButton16.Value = True Then
Sheets("Tableau").Range("L" & DERLIGNE) = 40
End If
'Maintenance
If OptionButton17.Value = True Then
Sheets("Tableau").Range("k" & DERLIGNE) = OptionButton17.Caption
End If
If OptionButton18.Value = True And OptionButton17.Value = True Then
Sheets("Tableau").Range("L" & DERLIGNE) = 20
End If
If OptionButton19.Value = True And OptionButton17.Value = True Then
Sheets("Tableau").Range("L" & DERLIGNE) = 40
End If
If OptionButton20.Value = True And OptionButton17.Value = True Then
Sheets("Tableau").Range("L" & DERLIGNE) = 40
End If
If OptionButton21.Value = True And OptionButton17.Value = True Then
Sheets("Tableau").Range("L" & DERLIGNE) = 40
End If
' Bonus vo
If CheckBox20 = True Then
Sheets("Tableau").Range("N" & DERLIGNE) = 50
Sheets("Tableau").Range("M" & DERLIGNE) = "Oui"
End If
If CheckBox20 = Fasle Then
Sheets("Tableau").Range("N" & DERLIGNE) = 0
Sheets("Tableau").Range("M" & DERLIGNE) = "Non"
End If
'Réinitialisation après validation
Unload Me
UserForm1.Show
End Sub
- Messages
- 2'417
- Excel
- 2019
- Inscrit
- 13/07/2017
- Emploi
- Formateur, animateur,tech.informatique
Bonjour toutes et tous
@Diapason66100
If CheckBox20 = Fasle ' False FAUX par :
If CheckBox20 = False ' correct@tester sans grande conviction que; cela fonctionne comme ceci
' [...]
'Réinitialisation après validation
UserForm1.Hide ' on le cache
Unload Me ' on le décharge ' lui ????
Load Userform1 ' on le charge
UserForm1.Show ' on l'affiche
End SubBonjour
Merci d'utiliser les balises de code </> disponibles dans le menu lorsque vous mettez un code dans votre post.
Pourquoi remettre le même code qu'ici --> https://forum.excel-pratique.com/excel/code-vba-renvoyer-a-la-ligne-dans-un-tableau-153134
Cordialement
Merci Andre 13
Pas facile de débuter