Copie ligne d'une listbox
Résolu
totof1868
Messages postés
6
Statut
Membre
-
f894009 Messages postés 17417 Date d'inscription Statut Membre Dernière intervention -
f894009 Messages postés 17417 Date d'inscription Statut Membre Dernière intervention -
Bonjour, je démarre en vba et je bloque sur ce code .A chaque fois que j'active mon bouton sauvegarde il ne les copie pas a la suite mais les remplace merci de votre aide.
je vous joint mon code
Private Sub CommandButton5_Click()
'Dim LigneDestination As Integer
' Dim DernLigne As Long
' LigneDestination = 2
' For i = 0 To ListBox3.ListCount - 1
' If ListBox3.Selected(i) = True Then
' With Sheets("Feuil2")
' Range("A65000").End(xlUp).Offset(1).Select
' .Cells(LigneDestination, 1) = ListBox3.List(i)
' .Cells(LigneDestination, 2) = ListBox3.List(i, 1)
' .Cells(LigneDestination, 3) = ListBox3.List(i, 2)
' .Cells(LigneDestination, 4) = ListBox3.List(i, 3)
' .Cells(LigneDestination, 5) = ListBox3.List(i, 4)
' .Cells(LigneDestination, 6) = ListBox3.List(i, 5)
' .Cells(LigneDestination, 7) = ListBox3.List(i, 6)
' .Cells(LigneDestination, 8) = ListBox3.List(i, 7)
' .Cells(LigneDestination, 9) = ListBox3.List(i, 8)
' .Cells(LigneDestination, 10) = ListBox3.List(i, 9)
' End With
' LigneDestination = LigneDestination + 1
' End If
' Next i
'End Sub
je vous joint mon code
Private Sub CommandButton5_Click()
'Dim LigneDestination As Integer
' Dim DernLigne As Long
' LigneDestination = 2
' For i = 0 To ListBox3.ListCount - 1
' If ListBox3.Selected(i) = True Then
' With Sheets("Feuil2")
' Range("A65000").End(xlUp).Offset(1).Select
' .Cells(LigneDestination, 1) = ListBox3.List(i)
' .Cells(LigneDestination, 2) = ListBox3.List(i, 1)
' .Cells(LigneDestination, 3) = ListBox3.List(i, 2)
' .Cells(LigneDestination, 4) = ListBox3.List(i, 3)
' .Cells(LigneDestination, 5) = ListBox3.List(i, 4)
' .Cells(LigneDestination, 6) = ListBox3.List(i, 5)
' .Cells(LigneDestination, 7) = ListBox3.List(i, 6)
' .Cells(LigneDestination, 8) = ListBox3.List(i, 7)
' .Cells(LigneDestination, 9) = ListBox3.List(i, 8)
' .Cells(LigneDestination, 10) = ListBox3.List(i, 9)
' End With
' LigneDestination = LigneDestination + 1
' End If
' Next i
'End Sub
1 réponse
-
Bonjour,
Private Sub CommandButton5_Click() Dim LigneDestination As Integer For i = 0 To ListBox3.ListCount - 1 If ListBox3.Selected(i) = True Then With Worksheets("Feuil2") LigneDestination = Range("A" & Rows.Count).End(xlUp).Row + 1 If LigneDestination < 2 Then LigneDestination = 2 .Cells(LigneDestination, 1) = ListBox3.List(i) .Cells(LigneDestination, 2) = ListBox3.List(i, 1) .Cells(LigneDestination, 3) = ListBox3.List(i, 2) .Cells(LigneDestination, 4) = ListBox3.List(i, 3) .Cells(LigneDestination, 5) = ListBox3.List(i, 4) .Cells(LigneDestination, 6) = ListBox3.List(i, 5) .Cells(LigneDestination, 7) = ListBox3.List(i, 6) .Cells(LigneDestination, 8) = ListBox3.List(i, 7) .Cells(LigneDestination, 9) = ListBox3.List(i, 8) .Cells(LigneDestination, 10) = ListBox3.List(i, 9) End With End If Next i End Sub-
-
-
-
Je t’explique je démarre en vba , très modestement et j'ai crée un userform avec recherche ,insertion et suppression de matériels. j'ai une listbox qui affiche ou toute la liste ,ou recherche par bâtiment .Quand je sélectionne mon bouton save après avoir choisis mes appareils dans la liste box. Il faudrait que sa sauvegarde sur feuil 2.
Par contre comment envoyez le fichier complet ? -
Bonjour,
Oui pour le fichier, car chez moi ce code fait ce que vous avez demande.
Pour transmettre un fichier,
Veillez a ce qu'il n'y ait PAS DE DONNEES CONFIDENTIELLES
il faut passer par un site de piËce jointe tel que cjoint.com
Allez sur ce site : https://www.cjoint.com/
Clic sur parcourir,
Cherche ton fichier,
clic sur ouvrir,
Clic sur "CrÈer le lien cjoint",
Copier le lien,
Revenir ici le coller dans une rÈponse...
-