'练练眼力,,,
Option Explicit
Sub test()
Dim arr(3), mark, i, j, k, t
arr(0) = Range("b3:g" & Cells(Rows.Count, "b").End(xlUp).Row).Value
mark = [b2].Resize(, UBound(arr(0), 2)).Value
ReDim temp(1 To 2, 1 To UBound(arr(0), 2)), brr(1 To UBound(arr(0), 1), 1 To 2 * UBound(arr(0), 2))
For i = 1 To UBound(arr)
arr(i) = arr(0)
Next
For i = 1 To UBound(arr(0), 1)
For j = 1 To UBound(arr(0), 2)
temp(1, j) = arr(0)(i, j)
temp(2, j) = mark(1, j)
If temp(1, j) = 0 Then temp(1, j) = 10 ^ 8
Next
For j = 1 To UBound(temp, 2) - 1
For k = j + 1 To UBound(temp, 2)
If temp(1, j) > temp(1, k) Then
t = temp(1, j): temp(1, j) = temp(1, k): temp(1, k) = t
t = temp(2, j): temp(2, j) = temp(2, k): temp(2, k) = t
End If
Next
Next
For j = 1 To UBound(temp, 2)
If temp(1, j) < 10 ^ 8 Then
arr(1)(i, j) = temp(1, j)
arr(2)(i, j) = temp(2, j)
arr(3)(i, j) = temp(1, j) & "-" & temp(2, j)
brr(i, 2 * j - 1) = temp(1, j)
brr(i, 2 * j) = temp(2, j)
Else
For k = 1 To 3
arr(k)(i, j) = vbNullString
Next
End If
Next
Next
mark = Split("?,l,u,ae", ",")
For i = 1 To 3
Range(mark(i) & 3).Resize(UBound(arr(i), 1), UBound(arr(i), 2)) = arr(i)
Next
[ap3].Resize(UBound(brr, 1), UBound(brr, 2)) = brr
End Sub |