|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Option Explicit
Sub test()
Dim arr, brr, dic, i, j, t, n
Set dic = CreateObject("scripting.dictionary")
With Sheets("sheet2")
arr = .Range("a8:p" & .Cells(Rows.Count, "o").End(xlUp).Row)
End With
brr = arr
For i = 1 To UBound(brr, 1) - 1
For j = i + 1 To UBound(brr, 1)
If brr(i, 4) > brr(j, 4) Then
t = brr(i, 4): brr(i, 4) = brr(j, 4): brr(j, 4) = t
End If
Next j, i
For i = 1 To UBound(brr, 1)
If brr(i, 4) > 3 And Not dic.exists(brr(i, 4)) Then dic(brr(i, 4)) = vbNullString
If dic.Count = 5 Then Exit For
Next
For i = 1 To UBound(arr, 1)
If dic.exists(arr(i, 4)) Then
n = n + 1
For j = 1 To UBound(arr, 2): arr(n, j) = arr(i, j): Next
End If
Next
With Sheets("五小").[a10]
.Resize(Rows.Count - 9, UBound(arr, 2)).ClearContents
If n > 0 Then .Resize(n, UBound(arr, 2)) = arr
End With
End Sub |
评分
-
1
查看全部评分
-
|