注册 登录
编程论坛 Excel/VBA论坛

VBA计数器求助

sharpex1 发布于 2023-08-07 17:21, 453 次点击
’ 汇总并输出
   
程序代码:
lastRow = Cells(Rows.Count, "C").End(xlUp).Row
    Set dict = CreateObject("Scripting.Dictionary")
    For i = 2 To lastRow
        branch = Cells(i, "C").Value
        sum = Cells(i, "O").Value
        If dict.Exists(branch) Then
            dict(branch)(0) = dict(branch)(0) + 1
            dict(branch)(1) = dict(branch)(1) + sum
        Else
            dict(branch) = Array(1, sum)
        End If
    Next i

  请问下, 为什么这里的“dict(branch)(0) = dict(branch)(0) + 1” 和 “ dict(branch)(1) = dict(branch)(1) + sum”并没有实现计数和累加功能??
只有本站会员才能查看附件,请 登录


[此贴子已经被作者于2023-8-7 17:28编辑过]

0 回复
1