|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
加个重量汇总
- Sub ykcbf() '//2024.12.2
- Set d = CreateObject("Scripting.Dictionary")
- Set d1 = CreateObject("Scripting.Dictionary")
- With Sheets("Sheet1 (2)")
- r = .Cells(Rows.Count, 1).End(3).Row
- arr = .[a1].Resize(r, 22)
- End With
- ReDim zrr(1 To r, 1 To 10)
- With Sheets("Sheet1")
- rq1 = .[b3].Value
- rq2 = .[e3].Value
- For i = 4 To UBound(arr)
- rq = CDate(arr(i, 10))
- If rq >= rq1 And rq <= rq2 Then
- s = arr(i, 2)
- d(s) = d(s) + 1
- s = arr(i, 12)
- If Not d1.exists(s) Then
- m = m + 1
- d1(s) = m
- zrr(m, 1) = s
- For j = 16 To UBound(arr, 2)
- zrr(m, j - 14) = arr(i, j)
- Next
- Else
- r = d1(s)
- For j = 16 To UBound(arr, 2)
- zrr(r, j - 14) = zrr(r, j - 14) + arr(i, j)
- Next
- End If
- End If
- Next
- .[g3] = d.Count & "个"
- d.RemoveAll
- For i = 4 To UBound(arr)
- rq = CDate(arr(i, 10))
- If rq >= rq1 And rq <= rq2 Then
- s = arr(i, 2) & "-" & arr(i, 5)
- If Not d.exists(s) Then
- d(s) = arr(i, 4)
- End If
- End If
- Next
- Sum = 0
- For Each k In d.keys
- Sum = Sum + d(k)
- Next
- .[h3] = Sum & "个"
- .[a5].Resize(1000, 9) = ""
- .[a5].Resize(m, 9) = zrr
- For i = 5 To m + 4
- .Cells(i, "i") = Application.Sum(.Cells(i, 2).Resize(, 7))
- Next
- End With
- Set d = Nothing
- MsgBox "OK!"
- End Sub
复制代码
|
|