|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub qs()
- Dim arr, i, dic
- Set dic = CreateObject("scripting.dictionary")
- Set d2 = CreateObject("scripting.dictionary")
- With Sheet1
- arr = .Range("a1").CurrentRegion.Value
- ReDim brr(1 To 10000, 1 To 3)
- For i = 2 To UBound(arr)
- s = CDate(arr(i, 1))
- If Not dic.exists(s) Then
- dic(s) = Val(arr(i, 2))
- Else
- dic(s) = dic(s) & "," & Val(arr(i, 2))
-
- End If
- Next
- For Each k In dic.keys
- krr = Split(dic(k), ",")
- d2.RemoveAll
- For i = 0 To UBound(krr)
- m = UBound(krr) - 1
- For j = 0 To m
- If krr(j) < krr(j + 1) Then
- temp = krr(j)
- krr(j) = krr(j + 1)
- krr(j + 1) = temp
- End If
- Next
- j = j - 1
- Next
-
- For i = 0 To UBound(krr)
- d2(krr(i)) = krr(i)
- Next
- kk = d2.keys
- n = n + 1
- brr(n, 1) = k
- For i = 2 To UBound(arr)
- If CDate(arr(i, 1)) = k Then
- If Val(arr(i, 2)) = kk(0) Or Val(arr(i, 2)) = kk(1) Then
- brr(n, 2) = brr(n, 2) + 1
- brr(n, 3) = brr(n, 3) + Val(arr(i, 2))
- End If
- End If
- Next
- Next k
- .Range("g2").Resize(n, 3) = brr
- End With
- Set dic = Nothing: Set d2 = Nothing
- End Sub
复制代码 |
|