XL 2019 Doubler chaque ligne d'une colonne (Important SVP)

cloud7801

XLDnaute Nouveau
Bonjour,

Je me permet d'envoyer un message car au taff j'ai un excel comptable à faire, mais je bloque sur une commande.
En gros, ma colonne E reprensente les identifiants clients (il y en a 500), qui ressemble a sa :
188524
189736
187445
184297
....
Moi j'aimerais que cela devienne
188524
188524
189736
189736
187445
187445
184297
184297

Doubler chaque ligne, quelqu'un aurait une idée svp je bloque depuis ce matin

MERCIIIIIIII
 

Dudu2

XLDnaute Barbatruc
Ach so !
Par exemple :
E F
C'était donc des colonnes ! Wouah.
VB:
Sub Test_DoubleLignesColonne()
    Call DoubleLignesColonne(ActiveSheet, 5, "PLVT 03/2022 FACTURE CTR ")
End Sub

Sub DoubleLignesColonne(Wsh As Worksheet, NoColonne As Integer, AjoutChaine As String)
    Dim Tab1() As Variant
    Dim Tab2() As Variant
    Dim NbLignes As Long
    Dim i As Long
    Const NbLignesTitre = 0
 
    With Wsh
        'Défiltrer pour ne pas fausser le xlUp avec des lignes de fin filtrées
        If Not .AutoFilter Is Nothing Then .AutoFilter.ShowAllData
        NbLignes = .Cells(Rows.Count, NoColonne).End(xlUp).Row
 
        Tab1 = .Cells(NbLignesTitre + 1, NoColonne).Resize(NbLignes - NbLignesTitre).Value
        ReDim Tab2(1 To UBound(Tab1, 1) * 2, 1 To 2)
 
        For i = 1 To UBound(Tab1, 1)
            Tab2(i * 2 - 1, 1) = Tab1(i, 1)
            Tab2(i * 2, 1) = Tab1(i, 1)
            Tab2(i * 2 - 1, 2) = AjoutChaine & Tab1(i, 1)
            Tab2(i * 2, 2) = AjoutChaine & Tab1(i, 1)
        Next i
 
        .Cells(NbLignesTitre + 1, NoColonne).Resize(UBound(Tab2, 1), UBound(Tab2, 2)).Value = Tab2
    End With
End Sub
 
Dernière édition:

Statistiques des forums

Discussions
312 480
Messages
2 088 757
Membres
103 950
dernier inscrit
Thomas Solioz