|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub qs()
- Dim arr, i, dic, sht As Worksheet
- Set dic = CreateObject("scripting.dictionary")
- Set dic = CreateObject("scripting.dictionary")
- ReDim brr(1 To 1000, 1 To 5)
- ReDim crr(1 To 1000, 1 To 5)
- For Each sht In Sheets
- If InStr("max,min", sht.Name) = 0 Then
- arr = sht.Range("a1").CurrentRegion.Value
- For i = 1 To UBound(arr)
- s = arr(i, 2)
- If Not dic.exists(s) Then
- m = m + 1: n = n + 1
- dic(s) = m
- For c = 1 To 5
- brr(m, c) = arr(i, c)
- crr(m, c) = arr(i, c)
- Next
- Else
- r = dic(s)
- If arr(i, 3) > brr(r, 3) Then
- For c = 1 To 5
- brr(r, c) = arr(i, c)
- Next
- ElseIf arr(i, 3) < crr(r, 3) Then
- For c = 1 To 5
- crr(r, c) = arr(i, c)
- Next
- End If
- End If
-
- Next
- End If
- Next
- Sheet1.Range("a2").Resize(m, 5) = brr
- Sheet8.Range("a2").Resize(m, 5) = crr
- Set dic = Nothing
- End Sub
复制代码 |
|