Erreur de Compilation VBA (erreur d'execution 424)

Fermé
qnaeb Messages postés 4 Date d'inscription lundi 14 mai 2018 Statut Membre Dernière intervention 18 mai 2018 - 14 mai 2018 à 18:49
qnaeb Messages postés 4 Date d'inscription lundi 14 mai 2018 Statut Membre Dernière intervention 18 mai 2018 - 18 mai 2018 à 22:28
Bonjour

sur le button commande je n'arrive pas à enregistrer les données dans le formulaire
Le blocage se fait sur Me.description !!

Private Sub CommandButton1_Click()
If Me.description</gras> = "" Or Me.categorie.ListIndex < 0 Or Me.ListIndex < 0 Or Me.txtdate = "" Or Me.somme = "" Or Me.compte.ListIndex < 0 Or Me.creancier = "" Then
MsgBox ("Il manque des informations")
Else

'Controler si la base de données est vide oui ou non
If Sheets("input").Range("B3") <> "" Then
Sheets("input").ListObjects(1).ListRow.Add
End If

'Trouver la dernière ligne et ajouter nos informations
dlt = Sheets("input").Range("b454653").End(x1up).Row

'Désormais ajouter nos informations
Sheets("input").Range("c" & dlt) = txtdate
Sheets("input").Range("d" & dlt) = "sortie"
Sheets("input").Range("e" & dlt) = CDbl(Me.somme)
Sheets("input").Range("f" & dlt) = Me.compte.Column(1)
Sheets("input").Range("g" & dlt) = Me.creancier
Sheets("input").Range("h" & dlt) = Me.description
Sheets("input").Range("i" & dlt) = Me.categorie
Sheets("input").Range("k" & dlt) = Me.subcat
Sheets("input").Range("m" & dlt) = Me.ref
Sheets("input").Range("n" & dlt) = Me.remarque

'Tout vider
Me.txtdate = ""
Me.compte = ""
Me.creancier = ""
Me.somme = ""
Me.categorie = ""
Me.subcat.RowSource = "sortie" & Me.categorie
Me.ref = ""
Me.remarque = ""
Me.description = ""

ThisWorkbook.RefreshAll
ThisWorkbook.Save
Me.ListBox1.RowSource = "compte"

End If

End Sub

3 réponses

thev Messages postés 1851 Date d'inscription lundi 7 avril 2008 Statut Membre Dernière intervention 15 avril 2024 681
Modifié le 16 mai 2018 à 09:55
Bonjour,


 

    With Sheets("input").ListObjects(1)
        'Controler si la base de données est vide oui ou non
        'Trouver la dernière ligne et ajouter nos informations
        Set cell = .ListColumns(1).Range.Find("")
        If cell Is Nothing Then .ListRows.Add: dlt = .ListRows.Count _
        Else dlt = cell.Row - .HeaderRowRange.Row
        
        'Désormais ajouter nos informations
        .ListColumns(1).DataBodyRange.Rows(dlt) = txtdate
        .ListColumns(2).DataBodyRange.Rows(dlt) = "sortie"
        .ListColumns(3).DataBodyRange.Rows(dlt) = CDbl(Me.somme)
        .ListColumns(4).DataBodyRange.Rows(dlt) = Me.compte.Column(1)
        .ListColumns(5).DataBodyRange.Rows(dlt) = Me.creancier
        .ListColumns(6).DataBodyRange.Rows(dlt) = Me.Description
        .ListColumns(7).DataBodyRange.Rows(dlt) = Me.categorie
        .ListColumns(8).DataBodyRange.Rows(dlt) = Me.subcat
        .ListColumns(9).DataBodyRange.Rows(dlt) = Me.ref
        .ListColumns(10).DataBodyRange.Rows(dlt) = Me.remarque

    End With


Pour prévoir l'ajout ou la modification d'une colonne, il est mieux d'indiquer le nom de la colonne de l'objet tableau. Comme ceci :
.Listcolumns("nom_de_la_colonne")

1
qnaeb Messages postés 4 Date d'inscription lundi 14 mai 2018 Statut Membre Dernière intervention 18 mai 2018
18 mai 2018 à 22:28
Merci beaucoup
grâce à vous cela a fonctionné
Bonne soirée
0
julia Namor Messages postés 524 Date d'inscription jeudi 27 mars 2014 Statut Membre Dernière intervention 13 janvier 2024 33
14 mai 2018 à 20:24
Bonjour
il faudrait renommer le
description</gras>

en retirant le
/

bien cordialement
0
qnaeb Messages postés 4 Date d'inscription lundi 14 mai 2018 Statut Membre Dernière intervention 18 mai 2018
15 mai 2018 à 13:15
Ok Merci
mais je travail sous visual basic excel 2016
cela ne m'aide pas mais je reste ouvert à d'autre proposition
0
thev Messages postés 1851 Date d'inscription lundi 7 avril 2008 Statut Membre Dernière intervention 15 avril 2024 681
15 mai 2018 à 22:06
Bonsoir,

A mon avis, ce serait plutôt :
If Me.description.Font.Bold = 0 …………………..

0
qnaeb Messages postés 4 Date d'inscription lundi 14 mai 2018 Statut Membre Dernière intervention 18 mai 2018
16 mai 2018 à 08:33
Merci pour l'info
Cela fonctionne jusqu'à la ligne " MsgBox"
Cela m'indique la valeur contenu dans la MsgBox 'Il manque des informations'
J'avance .... les amis, mais j'ai encore besoin de soutien
0