|
Option Explicit
Sub TEST2()
Dim ar
Application.ScreenUpdating = False
ar = [A1].CurrentRegion.Value
bSort ar, 2, UBound(ar), 3, 3, 3
[R1].CurrentRegion.ClearContents
[R1].Resize(UBound(ar), UBound(ar, 2)) = ar
Application.ScreenUpdating = True
Beep
End Sub
Function bSort(ByRef ar, ByVal iFirst&, ByVal iLast&, ByVal iLeft&, _
ByVal iRight&, ByVal iKey&, Optional isOrder As Boolean = True)
Dim i&, j&, k&, vTemp
For i = iFirst To iLast - 1
For j = iFirst To iLast + iFirst - 1 - i
If ar(j, iKey) <> ar(j + 1, iKey) Then
If ar(j, iKey) < ar(j + 1, iKey) Xor isOrder Then
For k = iLeft To iRight
vTemp = ar(j, k)
ar(j, k) = ar(j + 1, k)
ar(j + 1, k) = vTemp
Next
End If
End If
Next j
Next i
End Function
|
|