简体   繁体   中英

EXCEL: SUMIF with 3 criteria across 2 rows and columns

See the data in the image below. I want to calculate the sum of all budgets, planned and actual values for a given Costcode for all months until current month (current month is July).

I tried sumifs and sumproduct as well but couldn't get it to work. Can someone help me?

I appreciate your help a lot.

在此处输入图片说明

With 50345 in AO2, try it as,

=SUMPRODUCT((A3:A9=AO2)*(B1:AM1<=7)*(MOD(COLUMN(B:AM), 4)<>1)*B3:AM9)

在此处输入图片说明

Your screenshot has some columns hidden, but I assumed that the pattern continued. I also assumed that you would want these totals to change automatically as the months go by. With that being the case, I continued your pattern out for 12 months. Then, I put in 4 summary columns. One for each code vertically and one for each row header. Then, I created this formula in cell AX3 (and copied right and down):

    =SUMIFS($B3:$AW3,$B$2:$AW$2,AX$2,$B$1:$AW$1,"<="&(MONTH(TODAY())))

It is an array formula. If you have never used an array formula, follow these steps:

  1. select the formula from this page
  2. copy it
  3. go to excel
  4. select cell AX3,
  5. press the 'F2' key
  6. paste the formula
  7. press CTRL+SHIFT+Enter (instead of just pressing enter)

To copy down, follow these steps:

  1. Copy cell AX3
  2. Move down to cell AX4 (instead of selecting a range)
  3. Paste in cell AX4
  4. Select your range and paste from there.

If you don't copy down in this manner, it will tell you that you cannot change the array...

我的答案的屏幕截图

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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