|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub qs()
- Dim arr, i, dic
- Set dic = CreateObject("scripting.dictionary")
- arr = Sheet4.Range("a1").CurrentRegion.Value
- y2 = Val(Sheet2.[A1].Value)
- ReDim brr(1 To UBound(arr), 1 To 3)
- For i = 2 To UBound(arr)
- y = VBA.Month(CDate(arr(i, 3)))
- s = arr(i, 8)
- If y = y2 Then
- If Not dic.exists(s) Then
- m = m + 1
- dic(s) = m
- brr(m, 1) = s: brr(m, 2) = arr(i, 10): brr(m, 3) = arr(i, 12)
- Else
- rw = dic(s)
- brr(rw, 2) = brr(rw, 2) + arr(i, 10)
- brr(rw, 3) = brr(rw, 3) + arr(i, 12)
- End If
- End If
- Next
- Sheet2.Range("b2").Resize(10000, 3) = Empty
- Sheet2.Range("b2").Resize(m, 3) = brr
- End Sub
复制代码 |
|