简体   繁体   English

Excel公式获取根据另一列的特定数据

[英]Excel formula to get specific data that according to another column

I have a spreadsheet that contains various sheets, each sheet contains different types of orders including items, descriptions, quantity, etc. 我有一个包含各种工作表的电子表格,每个工作表都包含不同类型的订单,包括项目,描述,数量等。

ITEM    DESCRIPTION    QTY
Apple    ...            1
Orange   ...            4

I would like to get a formula that is capable to find out the total quantity of items from every sheet. 我想得到一个公式,该公式能够找出每张纸上的物品总数。

If you want to do it in a single cell, I'm afraid the only way of doing so without VBA is to make a manual search over all the pages : 如果要在单个单元格中执行此操作,恐怕没有VBA的唯一方法是手动搜索所有页面:

= SUMIF(Page1!A:A,"=ItemName",Page1!C:C)+ SUMIF(Page2!A:A,"=ItemName",Page2!C:C)+ ... = SUMIF(Page1!A:A,“ = ItemName”,Page1!C:C)+ SUMIF(Page2!A:A,“ = ItemName”,Page2!C:C)+ ...

Other solutions would involve you creating your own personal vba function or adding new cells in each sheet which I'm not sure are within the realms of possibilities. 其他解决方案将涉及您创建自己的个人vba函数或在每张工作表中添加新的单元格,但我不确定这些单元格是否可能。

If all your sheets with "data" on them are the same format, you can save time and maintenance by doing the following: 如果所有带有“数据”的工作表都采用相同的格式,则可以通过以下操作节省时间和维护:

create a sheet called start which is before all the "data" sheets. 创建一个名为start的工作表,该工作表位于所有“数据”工作表之前。 This sheet should be blank (except perhaps for a bit of text saying "this sheet is intentionally blank") 此工作表应为空白(也许有一点文字说“此工作表故意为空白”)

create a sheet called end which is after all the "data" sheets. 创建一个名为end的工作表,该工作表位于所有“数据”工作表之后。

Then in your summary sheet, you can do =SUM(start:end!C:C) (I'm assuming your quantity is in column C from your example above). 然后,在摘要表中,您可以执行=SUM(start:end!C:C) (我假设您的数量在上述示例的C列中)。

If you use this approach, you can easily add sheets in between start and end ; 如果使用这种方法,则可以轻松地在开始结束之间添加图纸; the formula will not need to be rewritten 该公式将不需要重写

Per @l3echod's comment in another answer, you can also use this pattern in SUMIF and SUMIFS formulae, if you want total quantity per item : 根据@ l3echod在另一个答案中的评论,如果您希望每件商品的总量,也可以在SUMIF和SUMIFS公式中使用此模式:

=SUMIF(start:end!$A:$A,$A2,start:end!$C:$C)

this assumes the item in question is in cell A2. 这假定所讨论的项目在单元格A2中。 Note that depending on the volume of data you have, this might be a slow formula to calculate. 请注意,根据您拥有的数据量,这可能是计算速度很慢的公式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM