|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
按照条件求和Function过程,根据每个部门统计月份小计。
自己写了个但是不对求解。。。
qiuhe.rar
(18.92 KB, 下载次数: 9)
- Function AAA(a As Range, b As Range)
- Dim i&, n&
- Dim arr, brr
- Dim d As Object
- Dim ws As Worksheet
- Set d = CreateObject("scripting.dictionary")
- For Each ws In Worksheets
- If ws.Name = a Then
- ws.Select
- d.RemoveAll
- With ws
- r = .UsedRange.Find(what:="*", LookIn:=xlValues, lookat:=xlWhole, searchorder:=xlByRows, searchdirection:=xlPrevious).Row
- brr = .Range("a1:k" & r)
- arr = .Range("a1:k" & r)
- For i = 4 To Range("B65536").End(xlUp).Row
- If brr(i, 1) = b Then
-
- For n = i To Range("B65536").End(xlUp).Row
- If arr(n, 2) = "小计" Then
- d(arr(n, 2)) = d(arr(n, 2)) + arr(n, 3)
- End If
- If Right(arr(n, 1), 1) = "月" Then GoTo X
-
- Next
- End If
- Next
- X:
- AAA = Application.Sum(d.items)
- End With
- End If
- Next
- End Function
复制代码
|
|