Rendre le remplissage des champs d'un formulaire obligatoire
kawtdanne
Messages postés
12
Statut
Membre
-
kawtdanne Messages postés 12 Statut Membre -
kawtdanne Messages postés 12 Statut Membre -
Bonjour, j'ai réalisé un formulaire Excel, je voudrai savoir comment faire pour rendre le remplissage des champs obligatoire à part le commentaire (COM), le code VBA est ci-joint. Merci
Private Sub CommandButton1_Click()
Dim no_ligne As Long
no_ligne = Range("D65536").End(xlUp).Row + 1
Dim Benef, Montant, CR, Compte, TVA As String
If OBBenefO.Value = True Then Benef = OBBenefO.Caption
If OBBenefN.Value = True Then Benef = OBBenefN.Caption
If OBMontantO.Value = True Then Montant = OBMontantO.Caption
If OBMontantN.Value = True Then Montant = OBMontantN.Caption
If OBTVAO.Value = True Then TVA = OBTVAO.Caption
If OBTVAN.Value = True Then TVA = OBTVAN.Caption
If OBCRO.Value = True Then CR = OBCRO.Caption
If OBCRN.Value = True Then CR = OBCRN.Caption
If OBCompteO.Value = True Then Compte = OBCompteO.Caption
If OBCompteN.Value = True Then Compte = OBCompteN.Caption
'Insertion des valeurs sur la feuille
Cells(no_ligne, 1) = Date
Cells(no_ligne, 2) = ComboBox1.Value
Cells(no_ligne, 3) = ComboBox3.Value
Cells(no_ligne, 4) = Dossier.Value
Cells(no_ligne, 5) = Benef
Cells(no_ligne, 6) = Montant
Cells(no_ligne, 7) = TVA
Cells(no_ligne, 8) = Compte
Cells(no_ligne, 9) = CR
Cells(no_ligne, 10) = COM
ThisWorkbook.Save
MsgBox ("Nouvel enregistrement effectué")
OBBenefO.Value = False
OBBenefN.Value = False
OBMontantO.Value = False
OBMontantN.Value = False
OBTVAO.Value = False
OBTVAN.Value = False
OBCRO.Value = False
OBCRN.Value = False
OBCompteO.Value = False
OBCompteN.Value = False
ComboBox1.ListIndex = -1
ComboBox3.ListIndex = -1
Dossier.Value = ""
COM.Value = ""
End Sub
Private Sub CommandButton1_Click()
Dim no_ligne As Long
no_ligne = Range("D65536").End(xlUp).Row + 1
Dim Benef, Montant, CR, Compte, TVA As String
If OBBenefO.Value = True Then Benef = OBBenefO.Caption
If OBBenefN.Value = True Then Benef = OBBenefN.Caption
If OBMontantO.Value = True Then Montant = OBMontantO.Caption
If OBMontantN.Value = True Then Montant = OBMontantN.Caption
If OBTVAO.Value = True Then TVA = OBTVAO.Caption
If OBTVAN.Value = True Then TVA = OBTVAN.Caption
If OBCRO.Value = True Then CR = OBCRO.Caption
If OBCRN.Value = True Then CR = OBCRN.Caption
If OBCompteO.Value = True Then Compte = OBCompteO.Caption
If OBCompteN.Value = True Then Compte = OBCompteN.Caption
'Insertion des valeurs sur la feuille
Cells(no_ligne, 1) = Date
Cells(no_ligne, 2) = ComboBox1.Value
Cells(no_ligne, 3) = ComboBox3.Value
Cells(no_ligne, 4) = Dossier.Value
Cells(no_ligne, 5) = Benef
Cells(no_ligne, 6) = Montant
Cells(no_ligne, 7) = TVA
Cells(no_ligne, 8) = Compte
Cells(no_ligne, 9) = CR
Cells(no_ligne, 10) = COM
ThisWorkbook.Save
MsgBox ("Nouvel enregistrement effectué")
OBBenefO.Value = False
OBBenefN.Value = False
OBMontantO.Value = False
OBMontantN.Value = False
OBTVAO.Value = False
OBTVAN.Value = False
OBCRO.Value = False
OBCRN.Value = False
OBCompteO.Value = False
OBCompteN.Value = False
ComboBox1.ListIndex = -1
ComboBox3.ListIndex = -1
Dossier.Value = ""
COM.Value = ""
End Sub
A voir également:
- Rendre le remplissage des champs d'un formulaire obligatoire
- Whatsapp formulaire opposition - Guide
- Formulaire de réclamation facebook compte désactivé - Guide
- Un formulaire rempli - Guide
- Comment nettoyer son mac pour le rendre plus rapide - Guide
- Formulaire de reclamation instagram - Guide
3 réponses
Bonjour,
vous pouvez tester que tous vos objets (combo, variables ...etc) ne sont pas vides
ex: ComboBox1<>"" , Benef <>""
ceci avant
'Insertion des valeurs sur la feuille
si le test est ok vous traitez l'enregistrement si non afficher une msgbox d'avertissement
A+
vous pouvez tester que tous vos objets (combo, variables ...etc) ne sont pas vides
ex: ComboBox1<>"" , Benef <>""
ceci avant
'Insertion des valeurs sur la feuille
si le test est ok vous traitez l'enregistrement si non afficher une msgbox d'avertissement
A+