|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
'猜一个,假设A列有序。如果无序需要再加个排序函数处理一下,,,
Option Explicit
Sub test()
Dim i, j, k, pos, min, arr
[c2].Resize(Rows.Count - 1).Interior.ColorIndex = xlNone
arr = Range("a1:c" & Cells(Rows.Count, "a").End(xlUp).Row + 1)
For i = 2 To UBound(arr, 1) - 1
For j = i To UBound(arr, 1) - 1
If arr(j, 1) <> arr(j + 1, 1) Then
If j > i Then
min = arr(i, 3): pos = i
For k = i + 1 To j
If min > arr(k, 3) Then min = arr(k, 3): pos = k
Next
Cells(pos, 3).Interior.Color = vbRed
End If
i = j: Exit For
End If
Next j, i
End Sub |
|