XL 2016 Remplir un tableau avec un userform.

Joseph Haroun

XLDnaute Junior
Bonjour/Bonsoir Forum !
J'ai une difficulté que je tiens à vous exposer sollicitant votre précieuse aide.
En effet je n'arrive pas à remplir les Tableaux excel à l'aide d'un userform. Il y a toujours une ligne vide entre la ligne d'en-tête et la ligne des premières données enregistrées. Comment peut-on corriger cela ? Merci d'avance pour votre aide.
Yussufa
 

Staple1600

XLDnaute Barbatruc
Re

Remplaces ton code existant dans l'userform par celui-ci
Code:
Private Sub CommandButton1_Click()
Dim oLo As Excel.ListObject, oNLig As ListRow
Set oLo = Sheets("Feuil1").ListObjects(1)
With oLo
    Set oNLig = .ListRows.Add(alwaysinsert:=True)
    oNLig.Range.Cells(1, 1).Resize(, 4) = Array(TextBox1, TextBox2, TextBox3, TextBox4)
End With
End Sub
 

Staple1600

XLDnaute Barbatruc
Re

Unload fait cela très bien la vidange ;)

Yusufu
Cette macro fait mieux le job ;)
VB:
Private Sub CommandButton1_Click()
Dim oLo As Excel.ListObject, oNLig As ListRow
Set oLo = Sheets("Feuil1").ListObjects(1)
With oLo
    If IsEmpty(.Range.Cells(2, 1)) Then
    .Range.Cells(2, 1).Resize(, 4) = Array(TextBox1, TextBox2, TextBox3, TextBox4)
    Else
    Set oNLig = .ListRows.Add(alwaysinsert:=True)
    oNLig.Range.Cells(1, 1).Resize(, 4) = Array(TextBox1, TextBox2, TextBox3, TextBox4)
    End If
End With
End Sub
 
Dernière édition:

Discussions similaires

  • Résolu(e)
Microsoft 365 Taille UserForm
Réponses
3
Affichages
358

Membres actuellement en ligne

Statistiques des forums

Discussions
312 361
Messages
2 087 626
Membres
103 611
dernier inscrit
sebboes