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 40 41 42 43 44
|
Private Sub CommandButton1_Click()
ActiveSheet.CommandButton1.Caption = "trier données "
Dim i, j, b, a As Integer
Dim nb_exch As Integer
nb_exch = Range(Cells(7, 5), Cells(7, 5).End(xlToRight)).Count
Range(Cells(85, 3), Cells(200, 12)).ClearContents
Range(Cells(71, 3), Cells(74, 3).End(xlToRight)).Select 'transpose le tableau
Selection.Copy
Range("C86").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=True
Range(Cells(88, 3), Cells(88, 3).End(xlDown)).Select 'reprend la première colonne du tableau et la coller
Selection.Copy
Range("C117").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False
Range(Cells(117, 3), Cells(177, 3).End(xlDown)).Select 'trie la 1ére colonne du tableau du plus petit au plus grand
Selection.Sort Key1:=Range("C117"), Order1:=xlAscending, Header:=xlGuess _
, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
With Sheets("trier")
For j = 1 To 4
For i = 1 To nb_exch
'recherche les valeurs correspondantes aux données de la 1ére colonne
.Cells(116 + i, 3 + j).Value = WorksheetFunction.VLookup(.Cells(116 + i, 3).Value, Sheets("trier").Range(Cells(88, 3), Cells(114, 7)), 1 + j, False) 'cold side
Next i
Next j
End With
End Sub |
Partager