XL 2019 Dupliquer ligne d'un tableau - dernière ligne

thespeedy20

XLDnaute Occasionnel
Bonjour à tous,

Je dois dupliquer, une ligne d'un tableau (choix par inputbox) quand cela est nécessaire, la coller juste après après celle-ci, j'y arrive avec la macro présente dans mon fichier, le soucis que si j'essaye de dupliquer la dernière ligne de mon tableau, il copie la ligne hors du tableau...

Merci d'avance pour votre aide
 

Pièces jointes

  • Dupli.xlsm
    20.7 KB · Affichages: 7
Solution
Bonsoir thespeedy20,

Utilisez le fait qu'il s'agit d'un tableau structuré :
VB:
With [Tableau1] 'tableau structuré
    For i = .Rows.Count To 1 Step -1
        If .Cells(i, 3) = nom Then
            .Rows(i + 1).Insert xlDown
            .Rows(i).Copy .Rows(i + 1)
            .Cells(i + 1, 12) = "2ème instrument"
        End If
    Next i
End With
A+

job75

XLDnaute Barbatruc
Bonsoir thespeedy20,

Utilisez le fait qu'il s'agit d'un tableau structuré :
VB:
With [Tableau1] 'tableau structuré
    For i = .Rows.Count To 1 Step -1
        If .Cells(i, 3) = nom Then
            .Rows(i + 1).Insert xlDown
            .Rows(i).Copy .Rows(i + 1)
            .Cells(i + 1, 12) = "2ème instrument"
        End If
    Next i
End With
A+
 

Pièces jointes

  • Dupli.xlsm
    21.2 KB · Affichages: 5

Discussions similaires