XL 2019 Transfer de données du formulaire vers un tableau après click sur le CommandButton1.

sgangbadjo

XLDnaute Nouveau
Please Help, j'ai un message d'erreur sur mon code ci-dessous



Private Sub CommandButton1_Click()

Msgbx "Confirma a adição de dados?", vbYesNo, "confirmation"

Dim derligne As Integer


If Msgbx("Confirma a adição de dados?", vbYesNo, "confirmation") = vbYes Then

derligne = Sheets("Ledger").Range("A:A1048576").End(x1Up).Row + 1

Cells(derligne, 1) = ComboBox1_mois.Value
Cells(derligne, 2) = TextBox1.Value
Cells(derligne, 3) = TextBox2.Value
Cells(derligne, 4) = TextBox3.Value
Cells(derligne, 5) = TextBox4.Value
Cells(derligne, 6) = TextBox5.Value
Cells(derligne, 7) = TextBox6.Value
Cells(derligne, 8) = TextBox7.Value
Cells(derligne, 9) = TextBox8.Value
Cells(derligne, 10) = TextBox9.Value
Cells(derligne, 11) = TextBox10.Value
Cells(derligne, 12) = TextBox11.Value
Cells(derligne, 13) = TextBox12.Value
Cells(derligne, 14) = TextBox13.Value
Cells(derligne, 15) = TextBox14.Value
Cells(derligne, 16) = TextBox15.Value
Cells(derligne, 17) = TextBox16.Value
Cells(derligne, 18) = TextBox17.Value
Cells(derligne, 19) = TextBox18.Value
Cells(derligne, 20) = TextBox19.Value

End If

Unload Me

End Sub
 

Jacky67

XLDnaute Barbatruc
Please Help, j'ai un message d'erreur sur mon code ci-dessous



Private Sub CommandButton1_Click()

Msgbx "Confirma a adição de dados?", vbYesNo, "confirmation"

Dim derligne As Integer


If Msgbx("Confirma a adição de dados?", vbYesNo, "confirmation") = vbYes Then

derligne = Sheets("Ledger").Range("A:A1048576").End(x1Up).Row + 1

Cells(derligne, 1) = ComboBox1_mois.Value
Cells(derligne, 2) = TextBox1.Value
Cells(derligne, 3) = TextBox2.Value
Cells(derligne, 4) = TextBox3.Value
Cells(derligne, 5) = TextBox4.Value
Cells(derligne, 6) = TextBox5.Value
Cells(derligne, 7) = TextBox6.Value
Cells(derligne, 8) = TextBox7.Value
Cells(derligne, 9) = TextBox8.Value
Cells(derligne, 10) = TextBox9.Value
Cells(derligne, 11) = TextBox10.Value
Cells(derligne, 12) = TextBox11.Value
Cells(derligne, 13) = TextBox12.Value
Cells(derligne, 14) = TextBox13.Value
Cells(derligne, 15) = TextBox14.Value
Cells(derligne, 16) = TextBox15.Value
Cells(derligne, 17) = TextBox16.Value
Cells(derligne, 18) = TextBox17.Value
Cells(derligne, 19) = TextBox18.Value
Cells(derligne, 20) = TextBox19.Value

End If

Unload Me

End Sub
Bonjour,
Msgbx=MsgBox(.......
Essaye avec
VB:
Private Sub CommandButton1_Click()
    Dim derligne&, i&
    If MsgBox("Confirma a adição de dados?", vbYesNo, "confirmation") = vbYes Then
        With Sheets("Ledger")
            derligne = .Cells(.Rows.Count, "A").End(xlUp).Row + 1
            .Cells(derligne, 1) = ComboBox1_mois.Value
            For i = 1 To 19
                .Cells(derligne, i + 1) = Controls("textbox" & i)
            Next
        End With
    End If
    Unload Me
End Sub
 
Dernière édition:

sylvanu

XLDnaute Barbatruc
Supporter XLD
Bonjour sgangbadjo, jacky
Je ne sais pas si c'est la seule erreur mais la ligne :
VB:
derligne = Sheets("Ledger").Range("A:A1048576").End(x1Up).Row + 1
est erronée. C'est A1048576 et non A:A1048576. De plus c'est xlUp et non x1Up. ( l minuscule et non 1 )
Code:
derligne = Sheets("Ledger").Range("A1048576").End(xlUp).Row + 1
 

Jacky67

XLDnaute Barbatruc
Bonjour sgangbadjo, jacky
Je ne sais pas si c'est la seule erreur mais la ligne :
VB:
derligne = Sheets("Ledger").Range("A:A1048576").End(x1Up).Row + 1
est erronée. C'est A1048576 et non A:A1048576. De plus c'est xlUp et non x1Up. ( l minuscule et non 1 )
Code:
derligne = Sheets("Ledger").Range("A1048576").End(xlUp).Row + 1
Hello sylvanu

Oui, j'ai vu,:cool: corrigé et raccourci ;)
 
Dernière édition:

Statistiques des forums

Discussions
311 711
Messages
2 081 794
Membres
101 817
dernier inscrit
carvajal