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
|
Sub tri()
Application.ScreenUpdating = False
Dim a, b As Integer
n = Range("A" & Rows.Count).End(xlUp).Row
Sheets("TRI").Select
Range("A3:E" & n).Sort Key1:=Range("B3"), Order1:=xlDescending, Header:= _
xlNo, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortTextAsNumbers
For j = 1 To 100
For i = n - 1 To 3 Step -1
If Cells(i, 1).Value = 12 Then
For y = 1 To n - i
If Cells(i + y, 1).Value < 12 Then
a = Cells(i, 1).Offset(0, 1).Resize(, 5).Value
Cells(i, 1).Value = Cells(i + y, 1).Value
Cells(i, 1).Offset(0, 1).Resize(, 5).Value = Cells(i + y, 1).Offset(0, 1).Resize(, 5).Value
Cells(i + y, 1).Value = 12
Cells(i + y, 1).Offset(0, 1).Resize(, 5).Value = a
Exit For
End If
Next
End If
Next
Next
End Sub |