|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 全党 于 2023-3-3 14:53 编辑
参与一下,才学VBA,见笑了。- Sub shishi()
- Dim arr, d
- Set d = CreateObject("scripting.dictionary")
- arr = Worksheets("数据源").Range("a1").CurrentRegion
- For i = 2 To UBound(arr)
- If arr(i, 2) = "Y" Then
- k = arr(i, 1): k1 = arr(i, 3): k2 = arr(i, 4)
- d(k & k1) = d(k & k1) + arr(i, 5)
- d(k2 & k1) = d(k2 & k1) + arr(i, 5)
- End If
- Next
-
- With Worksheets("统计表")
- For i = 2 To 6
- For j = 4 To 16
- If .Cells(j, 1) <> "" Then
- If d.exists(.Cells(j, 1) & .Cells(1, i)) Then
- .Cells(j, i) = d(.Cells(j, 1) & .Cells(1, i))
- End If
- End If
- Next
- Next
- End With
-
- End Sub
复制代码 |
|