Excel - SUMIF INDEX and MATCH

若如初见. 提交于 2019-12-24 01:29:15

问题


I'm stuck with a sumif formula. I think if I used some mix of index and match I could get it to work but I've been unable to do so for the past hour!

I need to sum from a table of numbers depending on the house number and 2 dates. For example, I need to sum the numbers for house 1 between dates 08-05-17 and 13-05-17.

My previous experience with index and match is that I've only every used it to get a single specific digit.


回答1:


OFFSET and INDIRECT are volatile, this is possible with INDEX/MATCH

=SUMIFS(INDEX(Sheet1!$W:$AC,MATCH("House " & B4,Sheet1!$A:$A,0),0),Sheet1!$W$3:$AC$3,"<=" & $AE4,Sheet1!$W$3:$AC$3,">=" & $AD4)

The 0 as the third criterion in the INDEX will return all the columns in the row chosen by the MATCH.

This formula is non volatile and non array.




回答2:


Modify the following

=SUMIFS(OFFSET(B3:ZZ3,MATCH("house 1",E:E,0)-3,0),B3:ZZ3,">"&42863,B3:ZZ3,"<"&42868)

Change "house 1" to a reference.

Change 42863 and 42868 to references of start date and end date respectively. (the numbers are just date in number formats.)

Change 3s in the ranges and the match formula to the row number containing the dates.

change B3:ZZ3 to the range of rows of your date. Assuming you are updating the data on a continuous basis, you can give space by increasing the range, as in my example to column ZZ.




回答3:


Assuming that:

  • First table is on Sheet1
  • House 1 data in first table is in row 4
  • Second table is on separate sheet
  • House 1 data in second table is in row 4

This formula in Sheet2, cell AG4 should work:

SUM(INDIRECT("Sheet1!R4C"&22+MATCH(AD4,Sheet1!W3:AC3,0),FALSE):INDIRECT("Sheet1!R4C"&22+MATCH(AE4,Sheet1!W3:AC3,0),FALSE))



回答4:


Formula for AI4 using arrays manipulation (normal formula though, not CSE):

=SUMPRODUCT(Sheet1!W4:XX100*
  (Sheet1!A4:A100 = "House " & A4)*
  (Sheet1!W3:XX3 >= AD4)*
  (Sheet1!W3:XX3 <= AE4))

p.s. Index/Match version should be (supposedly) faster, But I like this form for its readability...



来源:https://stackoverflow.com/questions/44216459/excel-sumif-index-and-match

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!