Copie ligne d'une listbox

Résolu/Fermé
totof1868 Messages postés 6 Date d'inscription vendredi 12 mai 2017 Statut Membre Dernière intervention 14 mai 2017 - Modifié le 12 mai 2017 à 22:14
f894009 Messages postés 17192 Date d'inscription dimanche 25 novembre 2007 Statut Membre Dernière intervention 16 juin 2024 - 14 mai 2017 à 20:24
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
A voir également:

1 réponse

f894009 Messages postés 17192 Date d'inscription dimanche 25 novembre 2007 Statut Membre Dernière intervention 16 juin 2024 1 708
13 mai 2017 à 08:31
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
0
totof1868 Messages postés 6 Date d'inscription vendredi 12 mai 2017 Statut Membre Dernière intervention 14 mai 2017
13 mai 2017 à 18:50
Je ne comprend plus rien , avec ton code sa ne fonctionne plus du tout.
sa fais des jours que je cherche .Merci beaucoup pour ton aide
0
totof1868 Messages postés 6 Date d'inscription vendredi 12 mai 2017 Statut Membre Dernière intervention 14 mai 2017 > totof1868 Messages postés 6 Date d'inscription vendredi 12 mai 2017 Statut Membre Dernière intervention 14 mai 2017
13 mai 2017 à 19:08
veux tu mon fichier pour voir si tu trouve d'ou vient le problème ,c un userform pour m'aider dans mon taf j’espère .
0
yg_be Messages postés 22909 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 27 juin 2024 1 480 > totof1868 Messages postés 6 Date d'inscription vendredi 12 mai 2017 Statut Membre Dernière intervention 14 mai 2017
13 mai 2017 à 19:38
cela me semble une bonne idée de partager ton fichier, en effet.
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.
0
totof1868 Messages postés 6 Date d'inscription vendredi 12 mai 2017 Statut Membre Dernière intervention 14 mai 2017 > yg_be Messages postés 22909 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 27 juin 2024
13 mai 2017 à 20:11
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 ?
0
f894009 Messages postés 17192 Date d'inscription dimanche 25 novembre 2007 Statut Membre Dernière intervention 16 juin 2024 1 708 > totof1868 Messages postés 6 Date d'inscription vendredi 12 mai 2017 Statut Membre Dernière intervention 14 mai 2017
14 mai 2017 à 07:09
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...
0