bonjour
je souhaite trier des lignes en fonction d'un nom tout en insérant une ligne à chaque changement de nom mais si un nom existe plusieurs fois je ne veux pas qu'une ligne soit insérée
voici le fichier source et le code pour mieux comprendre
quelqu'un peut t'il m'aider??? 🙂
Sub Tri_InserLigne()
Dim plg As Range, plg2 As Range
Dim i As Long
If Sheets("Relance").Range("A4") = "" Then Exit Sub
With Sheets("Relance")
Set plg = .Range("A4 : A" & .Range("A65536").End(xlUp).Row)
Set plg2 = .Range("A4" & ":" & "H" & .Range("H65536").End(xlUp).Row)
plg2.Sort Key1:=.Range("F4"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
For i = 1 To plg.Count * 2 - 1
If i Mod 2 = 0 Then
.Rows(i + 3).Insert Shift:=xlDown
.Range("A" & i + 3 & ":" & "H" & i + 3).Interior.ColorIndex = 35
End If
Next
End With
End Sub
je souhaite trier des lignes en fonction d'un nom tout en insérant une ligne à chaque changement de nom mais si un nom existe plusieurs fois je ne veux pas qu'une ligne soit insérée
voici le fichier source et le code pour mieux comprendre
quelqu'un peut t'il m'aider??? 🙂
Sub Tri_InserLigne()
Dim plg As Range, plg2 As Range
Dim i As Long
If Sheets("Relance").Range("A4") = "" Then Exit Sub
With Sheets("Relance")
Set plg = .Range("A4 : A" & .Range("A65536").End(xlUp).Row)
Set plg2 = .Range("A4" & ":" & "H" & .Range("H65536").End(xlUp).Row)
plg2.Sort Key1:=.Range("F4"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
For i = 1 To plg.Count * 2 - 1
If i Mod 2 = 0 Then
.Rows(i + 3).Insert Shift:=xlDown
.Range("A" & i + 3 & ":" & "H" & i + 3).Interior.ColorIndex = 35
End If
Next
End With
End Sub