'每位最大支持99,最大支持3级(可修改)
Option Explicit
Sub test()
Dim arr, i, j, k, t
With Sheets("排序前")
arr = .Range("a3:c" & .Cells(Rows.Count, "a").End(xlUp).Row)
End With
For i = 1 To UBound(arr, 1)
If InStr(arr(i, 1), ".") = 0 Then
arr(i, 3) = arr(i, 1) * 10 ^ 4
Else
t = Split(arr(i, 1), ".")
If UBound(t) = 1 Then
arr(i, 3) = t(0) * 10 ^ 4 + t(1) * 10 ^ 2
Else
arr(i, 3) = t(0) * 10 ^ 4 + t(1) * 10 ^ 2 + t(2)
End If
End If
Next
For i = 1 To UBound(arr, 1) - 1
For j = i + 1 To UBound(arr, 1)
If arr(i, 3) > arr(j, 3) Then
For k = 1 To UBound(arr, 2)
t = arr(i, k): arr(i, k) = arr(j, k): arr(j, k) = t
Next
End If
Next j, i
With Sheets("目标结果").[a3]
.Resize(Rows.Count - 2, 2).ClearContents
.Resize(UBound(arr, 1), 2) = arr
End With
End Sub |