erreur :"erreur définie par l'application ou par l'objet" je ne comprends pas

Squoltahthx94

XLDnaute Occasionnel
Bonjour à tout le forum,

J'ai un Usf me permettant de remplir des lignes via un bouton contenant ce code :

Code:
Private Sub bt_rec_Click()
Dim lig As Long
    With Sheets("BDD")
        lig = .Range("a2").End(xlDown).Row + 1
        .Range("a" & lig).Value = Me.Txt_date.Text
        .Range("b" & lig).Value = Me.CbxCptClt.Text    'Ecrit en A... la valeur de Textbox1
        .Range("c" & lig).Value = Me.TxtBxNom.Text    'etc....
        .Range("d" & lig).Value = Me.TxtBxVille.Text    'etc.....
        .Range("e" & lig).Value = Me.TxtBxCP.Text
        .Range("f" & lig).Value = Me.TxtBxAgence.Text
        .Range("g" & lig).Value = Me.CBoxLiaisonTlm.Text
        .Range("h" & lig).Value = Me.ComboBox5.Text
        .Range("i" & lig).Value = Me.ComboBox4.Text
        .Range("j" & lig).Value = Me.TextBox1.Text
        .Range("k" & lig).Value = Me.ComboBox6.Text
        .Range("l" & lig).Value = Me.ComboBox2.Text
        .Range("m" & lig).Value = Me.TextBox2.Text
        .Range("n" & lig).Value = Me.Systeme_Int.Text
        .Range("o" & lig).Value = Me.ComboBox8.Text
        .Range("p" & lig).Value = Me.TextBox3.Text
        .Range("q" & lig).Value = Me.cbxvideo.Text
        .Range("r" & lig).Value = Me.Video_oui_Non.Text
        .Range("s" & lig).Value = Me.ComboBox9.Text
        .Range("t" & lig).Value = Me.ComboBox13.Text
        .Range("u" & lig).Value = Me.Acces_oui_non.Text
        .Range("v" & lig).Value = Me.ComboBox7.Text
        .Range("w" & lig).Value = Me.ComboBox11.Text
        .Range("x" & lig).Value = Me.ComboBox16.Text
        .Range("y" & lig).Value = Me.cbx_type_inst.Text
        .Range("z" & lig).Value = Me.cbximplant.Text
        .Range("aa" & lig).Value = Me.tbx_tx_implant.Text
    End With
End Sub

dès que j'execute cette commande, Excel indique "erreur définie par l'application ou par l'objet" mais je ne comprend pas l'erreur... quelqu'un peu m'aider ??? Merci:mad::mad::mad::mad:
 

mutzik

XLDnaute Barbatruc
Re : erreur :"erreur définie par l'application ou par l'objet" je ne comprends pas

bonjour

mets un point d’arrêt dans ce code (click dans la marge, un rond brun apparait)
le code s’exécute jusque là
puis touche F8 qui exécute le code ligne après ligne, et tu verras ou est l'erreur
reclick sur le rond brun si tu veux enlever le point d'arrêt
 

Papou-net

XLDnaute Barbatruc
Re : erreur :"erreur définie par l'application ou par l'objet" je ne comprends pas

RE :

Apparemment, c'est la recherche de la dernière ligne qui est en cause.

Essaie en modifiant la quatrième ligne comme suit :

Code:
lig = .Range("a" & Rows.Count).End(xlUp).Row + 1
Par contre, je maintiens la remarque de mon premier message concernant les .Text.

Cordialement.
 

Squoltahthx94

XLDnaute Occasionnel
Re : erreur :"erreur définie par l'application ou par l'objet" je ne comprends pas

J'ai remplacé le code comme suit :
Code:
Private Sub bt_rec_Click()
Dim lig As Long
    With Sheets("BDD")
        lig = .Range("a3").End(xlUp).Row + 1
        .Range("a" & lig).Value = Me.Txt_date.Value
        .Range("b" & lig).Value = Me.CbxCptClt.Value    'Ecrit en A... la valeur de Textbox1
        .Range("c" & lig).Value = Me.TxtBxNom.Value    'etc....
        .Range("d" & lig).Value = Me.TxtBxVille.Value    'etc.....
        .Range("e" & lig).Value = Me.TxtBxCP.Value
        .Range("f" & lig).Value = Me.TxtBxAgence.Value
        .Range("g" & lig).Value = Me.CBoxLiaisonTlm.Value
        .Range("h" & lig).Value = Me.ComboBox5.Value
        .Range("i" & lig).Value = Me.ComboBox4.Value
        .Range("j" & lig).Value = Me.TextBox1.Value
        .Range("k" & lig).Value = Me.ComboBox6.Value
        .Range("l" & lig).Value = Me.ComboBox2.Value
        .Range("m" & lig).Value = Me.TextBox2.Value
        .Range("n" & lig).Value = Me.Systeme_Int.Value
        .Range("o" & lig).Value = Me.ComboBox8.Value
        .Range("p" & lig).Value = Me.TextBox3.Value
        .Range("q" & lig).Value = Me.cbxvideo.Value
        .Range("r" & lig).Value = Me.Video_oui_Non.Value
        .Range("s" & lig).Value = Me.ComboBox9.Value
        .Range("t" & lig).Value = Me.ComboBox13.Value
        .Range("u" & lig).Value = Me.Acces_oui_non.Value
        .Range("v" & lig).Value = Me.ComboBox7.Value
        .Range("w" & lig).Value = Me.ComboBox11.Value
        .Range("x" & lig).Value = Me.ComboBox16.Value
        .Range("y" & lig).Value = Me.cbx_type_inst.Value
        .Range("z" & lig).Value = Me.cbximplant.Value
        .Range("aa" & lig).Value = Me.tbx_tx_implant.Value
    End With
End Sub
Ok cela fonctionne mais je n'ajoute plus de ligne je ne remplace que la derniere.:confused::confused::confused:
 

Papou-net

XLDnaute Barbatruc
Re : erreur :"erreur définie par l'application ou par l'objet" je ne comprends pas

RE :

Tu n'as pas recopié la quatrième ligne comme je te l'ai indiqué : tu fais référence à la cellule Range("a3") au lieu de Range("a" & Rows.Count).

Cordialement.
 

Discussions similaires

Statistiques des forums

Discussions
312 251
Messages
2 086 623
Membres
103 266
dernier inscrit
moonie