|
Sub 分类排序()
Range("E3:F" & Rows.Count) = ""
Dim ARR, ARR1(), ARR2(), BM, CS
A = Cells(Rows.Count, "A").End(3).Row
ARR = Range("A3:B" & A)
A = UBound(ARR)
For B = 1 To A
BM = ARR(B, 1)
CS = ARR(B, 2)
If Len(BM) = 3 Then
C = C + 1
D = 0
ReDim Preserve ARR1(1 To 3, 1 To C)
ARR1(1, C) = BM
ARR1(2, C) = CS
Else
D = D + 1
If D = 1 Then
ReDim ARR2(1 To 2, 1 To 1)
Else
ARR2 = ARR1(3, C)
End If
ReDim Preserve ARR2(1 To 2, 1 To D)
ARR2(1, D) = BM
ARR2(2, D) = CS
ARR1(3, C) = ARR2
End If
Next B
For A = UBound(ARR1, 2) - 1 To 1 Step -1
For B = 1 To A
If ARR1(2, B) < ARR1(2, B + 1) Then
For C = 1 To 3
GDZ = ARR1(C, B)
ARR1(C, B) = ARR1(C, B + 1)
ARR1(C, B + 1) = GDZ
Next C
End If
Next B
Next A
For A = 1 To UBound(ARR1, 2)
B = Cells(Rows.Count, "E").End(3).Row + 1
Cells(B, "E") = ARR1(1, A)
Cells(B, "F") = ARR1(2, A)
ARR2 = ARR1(3, A)
For C = UBound(ARR2, 2) - 1 To 1 Step -1
For D = 1 To C
If ARR2(2, D) < ARR2(2, D + 1) Then
GDZ1 = ARR2(1, D)
GDZ2 = ARR2(2, D)
ARR2(1, D) = ARR2(1, D + 1)
ARR2(2, D) = ARR2(2, D + 1)
ARR2(1, D + 1) = GDZ1
ARR2(2, D + 1) = GDZ2
End If
Next D
Next C
B = Cells(Rows.Count, "E").End(3).Row + 1
Cells(B, "E").Resize(UBound(ARR2, 2), 2) = WorksheetFunction.Transpose(ARR2)
Next A
End Sub
|
|