1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| Sub Macro1()
'Partie tri selon pays et groupe
Range("a1").Activate
Columns("A:E").Select
Application.CutCopyMode = False
Selection.Sort Key1:=Range("D2"), Order1:=xlAscending, Key2:=Range("C2") _
, Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _
:=xlSortNormal
' Insertion ligne entre pays différent
Range("d2").Select
Do
pays1 = ActiveCell.Value
ActiveCell.Offset(rowoffset:=1, columnoffset:=0).Activate
pays2 = ActiveCell.Value
If pays1 <> pays2 Then Selection.EntireRow.Insert
If pays1 <> pays2 Then ActiveCell.Offset(rowoffset:=1, columnoffset:=0).Activate
Loop Until ActiveCell.Value = ""
End Sub |
Partager