XL 2013 inserer une ligne suivant critere

djedjeto

XLDnaute Junior
salue chers amis. juste besoin d'un code vba qui me permet d'inserer une ligne vide a chaque fois qu'il y a changement de valeur dans la colonne
 

Pièces jointes

  • essai.xlsx
    8.1 KB · Affichages: 11

Lolote83

XLDnaute Barbatruc
Bonjour,
Peut être comme ceci
Code:
Sub TEST()
    Application.ScreenUpdating = False
    xRef = [A2]
    xDerLig = Range("A1000").End(xlUp).Row
    For Each xCell In Range("A2:A" & xDerLig)
        If xCell.Value <> xRef Then
            xRef = xCell.Value
            xLig = xCell.Row
            Rows(xLig & ":" & xLig).Insert Shift:=xlDown
            xDerLig = Range("A1000").End(xlUp).Row
        End If
    Next xCell
    Application.ScreenUpdating = True
End Sub
@+ Lolote83
 

djedjeto

XLDnaute Junior
Bonjour,
Peut être comme ceci
Code:
Sub TEST()
    Application.ScreenUpdating = False
    xRef = [A2]
    xDerLig = Range("A1000").End(xlUp).Row
    For Each xCell In Range("A2:A" & xDerLig)
        If xCell.Value <> xRef Then
            xRef = xCell.Value
            xLig = xCell.Row
            Rows(xLig & ":" & xLig).Insert Shift:=xlDown
            xDerLig = Range("A1000").End(xlUp).Row
        End If
    Next xCell
    Application.ScreenUpdating = True
End Sub
@+ Lolote83
merci infiniment mon frere. exactement ce que je voulais. merci
 

Discussions similaires

Statistiques des forums

Discussions
312 326
Messages
2 087 311
Membres
103 513
dernier inscrit
adel.01.01.80.19