简体   繁体   English

Excel:如果满足条件,则对列和行求和

[英]Excel: Sum columns and rows if criteria is met

I have a sheet with product names in column I and then dates from there on. 我在I栏中有一个产品名称的工作表,然后从那里开始。 For each date there are numbers of how many pieces of a certain product have to be made. 每个日期都有一定数量的某种产品必须制成。 I'm trying to sum all those numbers based on a product type, ie: 我正在尝试根据产品类型对所有这些数字求和,即:

 I       K       L      M     ...

        30.8.   31.8.   1.9.   ...
MAD23     2       0      45    ...
MMR32     5       7      33    ...
MAD17    17      56       0    ...

MAD:    120  (2+0+45+17+56+0)
MMR:     45  (5+7+33)

What I'm doing now is sum the row first: 我现在正在做的是首先对行求和:

=SUM(K6:GN6) = SUM(K6:GN6)

MAD23 = 47
MMR32 = 45
MAD32 = 73

And then sum those numbers in column J based on part of the product name in column I: 然后根据第I列中的部分产品名称将J列中的这些数字相加:

=SUMIF(Sheet1!I6:I775;"MAD*";Sheet1!J6:J775) = SUMIF(!工作表Sheet1 I6:I775; “MAD *”;工作表Sheet1 J6:J775)

MAD = 120
MMR = 45

Is it possible to do this with just one formula per criteria? 每个条件仅用一个公式就能做到吗?

=SUM(IF(MID(Sheet1!I6:I775,1,3)="MAD",Sheet1!k6:gn775,""))

使用Ctrl + Shift + Enter

Just trying it on those three rows, I get 只是在那三行上尝试,我得到

=SUM($K$6:$M$8*(LEFT($I$6:$I$8,LEN(I10)-1)=LEFT(I10,LEN(I10)-1)))

which is an array formula and must be entered with Ctrl Shift Enter 这是一个数组公式,必须使用Ctrl Shift 输入

That's assuming that I10 is going to contain some characters followed by a colon and you want to match those with the first characters of I6:I8. 假设I10将包含一些字符,后跟一个冒号,并且您想将其与I6:I8的前几个字符匹配。

在此处输入图片说明

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

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