|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
'消息收到
'示例结果可能是错的或条件为最后第二个,注释行输出后用你的慧眼确认一下,,,
Option Explicit
Sub test()
Dim arr, i, j, k, kk, n, t
Cells.Interior.ColorIndex = xlNone
For i = 1 To 42 Step 14
n = 0
arr = Cells(42, i).CurrentRegion
For j = 1 To UBound(arr, 1)
For k = 1 To UBound(arr, 2) - 1
For kk = k + 1 To UBound(arr, 2)
If arr(j, k) < arr(j, kk) Then
t = arr(j, k): arr(j, k) = arr(j, kk): arr(j, kk) = t
End If
Next kk, k
If n < arr(j, UBound(arr, 2) - 2) Then n = arr(j, UBound(arr, 2) - 2) '可能为最后第二个(改为-1)
Next
' Cells(42, i + 42).Resize(UBound(arr, 1), UBound(arr, 2)) = arr
For j = 66 To Cells(Rows.Count, i).End(xlUp).Row
If Cells(j, i) >= n Then Cells(j, i).Interior.Color = vbRed: Exit For
Next j, i
End Sub |
|