按单位汇总,在一个单元格输出所有汇总结果,结果依次按数量单位罗列出来 ...
上传附件,说明需求
另外,扇 块盒之间有没有换算的必要?一起说明一下 这样??
=SUMIF($A$1:$A$5,"扇",$B$1:$B$5)&"扇"&SUMIF($A$1:$A$5,"块",$B$1:$B$5)&"块"&SUMIF($A$1:$A$5,"盒",$B$1:$B$5)&"盒" 附件如下,单位之间没有换算关系,每次统计的单位都可能不一样
用自定义函数解决问题了,以下自定义函数代码供参考
Function myhz(ByVal rng As Range) As String
arr = rng
Dim d
Set d = CreateObject("scripting.dictionary")
For i = 1 To UBound(arr)
d(arr(i, 1)) = d(arr(i, 1)) + arr(i, 2)
Next
myhz = ""
If d.Count > 0 Then
k = d.Keys
t = d.Items
For i = 0 To d.Count - 1
If t(i) <> 0 Then
myhz = myhz & t(i) & k(i)
End If
Next
End If
End Function
页:
[1]