vba 一起使用 SUMIF 和 VLOOKUP 函数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26780955/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Use SUMIF and VLOOKUP functions together
提问by user4223089
This is my problem:
这是我的问题:
Sheet 1 - Column A has "Item #" Sheet 2 - Column C has "Item #" Sheet 1 - Column E will have the formula Sheet 2 - Column G has "Item Qty" Sheet 2 - Column B has "Size"
What I want is to return sum of 'Item Qty' of a certain 'Item #' based on 'Size'.
我想要的是根据“大小”返回某个“项目编号”的“项目数量”的总和。
If Sheet1(A2) has Item # 123 I would like it to find all 123 Item #s in Sheet2 and return the sum of all those numbers ONLY IF the "Size" column equals my criteria, let's say "Medium".
如果 Sheet1(A2) 有 Item # 123,我希望它在 Sheet2 中找到所有 123 个 Item #s,并仅在“Size”列等于我的条件时才返回所有这些数字的总和,比如说“Medium”。
回答by pnuts
Please try:
请尝试:
=SUMIFS(Sheet2!G:G,Sheet2!C:C,Sheet1!A2,Sheet2!B:B,"Medium")
Above would be more flexible as:
以上会更灵活:
=SUMIFS(Sheet2!$G:$G,Sheet2!$C:$C,Sheet1!$A2,Sheet2!$B:$B,Sheet1!E)
where E1 contains "Medium". Then it could be copied across (say under F1 etc containing "Large" ...) to add up quantities for Large ... sizes of the item in A2 (and copied down for a different item #
in A3 of Sheet1).
其中 E1 包含“中”。然后它可以被复制(比如在 F1 下等包含“大”......)以添加 A2 中项目的大......尺寸的数量(并item #
在 Sheet1 的 A3 中向下复制)。