Alimenter un tableau
k
J essaye d alimenter un tableau structuré depuis une listbox avec une insertion d une nouvelle ligne a chaque copie de valeur.
la nouvelle ligne est inserée mais les valeurs de listbox s' ajoutent a partir de la 2eme ligne .
la première ligne reste toujours vide .
sauvez moi
Private Sub btnajoutart_Click()
' insert in the invoice one item from the product list
Sheets("FACTURATION").Activate
' annuler tous les filtres
'
Range("A17").Select
Range("A" & Rows.Count).End(xlUp).Offset(1).Select
'Selection.End(xlDown).Select
'Selection.Offset(1, 0).Select
Dim Derniere_ligne As Long
Derniere_ligne = Sheets("facturation").Range("A" & Rows.Count).End(xlUp).Row + 1
If LISTART.ListIndex = -1 Then
MsgBox "No product selected", vbExclamation
End If
ActiveCell = "XXXX"
'ActiveCell.Offset(0, 2).Value = TXTADRESSE
'ActiveCell.Offset(0, 3).Value = TXTPOST
'ActiveCell.Offset(0, 4).Value = TXTVILLE
'ActiveCell.Offset(0, 2).Value = TXTADRESSE
'ActiveCell.Offset(0, 7).Value = TXTCONTACT
'ActiveCell.Offset(0, 8).Value = TXTMAIL
'ActiveCell.Offset(0, 9).Value = TXTMOB
ActiveCell.Offset(1, 0).EntireRow.Insert xlShiftDown
'Selection.EntireRow.Insert
'Sheets(WS_FEUIL).Rows(i + 1).Insert
End SubBonjour,
Select, Activate, Offset devrait être bannis en VBA.
Alimenter un tableau structuré : voir ici
Sinon joindre le fichier KIVABIEN avec ton code.
A+
k
merci galopin 01 pour les exemples.
jai reussi a alimenter mon tableau avec ce code.a partir d un listbox des articles un bouton ajout art permet ,d'alimente ma facture ligne par ligne.
maintenant je souhaite empêcher les doublons dans ma facture .
comment proceder ???
Private Sub btnajoutart_Click()
Sheets("FACTURATION").Activate
If LISTART.ListIndex = -1 Then
MsgBox "pas d articles ", vbExclamation
Unload Me
'INTRODUIRECLIENT.Show
End If
'
Range("A19").Select
If Range("A20") = "" Then ' remplissage premiere ligne du tableau
Range("A20").Select
Range("A20") = Me.LISTART.Column(1, LISTART.ListIndex)
ActiveCell.Offset(0, 1).Value = Me.LISTART.Column(2, LISTART.ListIndex)
ActiveCell.Offset(0, 3).Value = Me.LISTART.Column(12, LISTART.ListIndex)
Else
Range("A" & Rows.Count).End(xlUp).Offset(1).Select
ActiveCell = Me.LISTART.Column(1, LISTART.ListIndex)
ActiveCell.Offset(0, 1).Value = Me.LISTART.Column(2, LISTART.ListIndex)
ActiveCell.Offset(0, 3).Value = Me.LISTART.Column(12, LISTART.ListIndex)
ActiveCell.Offset(1, 0).EntireRow.Insert xlShiftDown
'Selection.EntireRow.Insert
'Sheets(WS_FEUIL).Rows(i + 1).Insert
End If
End Subk
je galere avec ce code mais en vin
With Sheets("facturation"
For Each CELL In .Range("A20:A" & .Range("B65536").End(xlUp).Row)
If Not CELL = Me.LISTART.Column(1, LISTART.ListIndex) Then
' Mise en place des valeurs saisies
Range("A" & Rows.Count).End(xlUp).Offset(1).Select
ActiveCell = Me.LISTART.Column(1, LISTART.ListIndex)
ActiveCell.Offset(0, 1).Value = Me.LISTART.Column(2, LISTART.ListIndex)
ActiveCell.Offset(0, 3).Value = Me.LISTART.Column(12, LISTART.ListIndex)
ActiveCell.Offset(1, 0).EntireRow.Insert xlShiftDown
Exit For
Else
MsgBox "cette personne est déjà référencée dans la base"
btnajoutart.Enabled = False
End If
Next
End With