|
- Option Explicit
- Sub TEST2()
- Dim ar, t, i%, j%, z%, n%
- Application.ScreenUpdating = False
- ar = [A1].CurrentRegion.Value
- n = 2
- Do While n < 4
- For i = 2 To UBound(ar)
- For j = i + 1 To UBound(ar)
- If n = 2 Then
- If ar(i, n) < ar(j, n) Then
- For z = 1 To 3
- t = ar(i, z)
- ar(i, z) = ar(j, z)
- ar(j, z) = t
- Next z
- End If
- ElseIf n = 3 Then
- If ar(i, n) > ar(j, n) Then
- For z = 1 To 3
- t = ar(i, z)
- ar(i, z) = ar(j, z)
- ar(j, z) = t
- Next z
- End If
- End If
- Next j
- Next i
- n = n + 1
- Loop
- [k1].Resize(UBound(ar), 3) = ar
- Application.ScreenUpdating = True
- Beep
- End Sub
复制代码 |
|