Copie ligne d'une listbox
Résolu
totof1868
Messages postés
6
Date d'inscription
Statut
Membre
Dernière intervention
-
f894009 Messages postés 17277 Date d'inscription Statut Membre Dernière intervention -
f894009 Messages postés 17277 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
A voir également:
- Copie ligne d'une listbox
- Copie cachée - Guide
- Partager photos en ligne - Guide
- Copie écran samsung - Guide
- Copie disque dur - Guide
- Mètre en ligne - Guide
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
sa fais des jours que je cherche .Merci beaucoup pour ton aide
et de confirmer ce que tu souhaites obtenir: "il ne les copie pas a la suite mais les remplace" n'est pas une phrase très claire.
Par contre comment envoyez le fichier complet ?
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...