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 27 28 29 30 31 32 33 34 35 36 37 38 39
|
Sub Tri()
Dim chaine() As String
Range("A1").Select
Selection.CurrentRegion.Select
Selection.Copy
Sheets("DONNEES TRIEES").Select
Range("A1").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Selection.Sort Key1:=Range("B2"), Order1:=xlAscending, Key2:=Range("C2") _
, Order2:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, DataOption3:= _
xlSortNormal
nbrelig = Selection.Rows.Count
Cells(1, 4).Value = "TRI"
ReDim chaine(nbrelig)
chaine(2) = ""
For lig = 2 To nbrelig
For col = 2 To 3
chaine(lig) = chaine(lig) & Cells(lig, col).Value 'Concaténation par colonne
Next col
Next lig
For lig = 2 To nbrelig - 1
un = IIf(chaine(lig) = chaine(lig + 1), True, False)
If chaine(lig) = chaine(lig + 1) And un Then
Cells(lig, 4) = "X"
Cells(lig + 1, 4) = "X"
End If
Next lig
Selection.CurrentRegion.Select
Selection.Sort Key1:=Range("D2"), Order1:=xlAscending, Key2:=Range("B2") _
, Order2:=xlAscending, Key3:=Range("C2"), Order3:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, DataOption3:= _
xlSortNormal
Columns(4).ClearContents
End Sub |
Partager