简体   繁体   中英

Excel - SUMIF INDEX and MATCH

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.

我想总结的是

总和应该去哪里

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.

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.

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))

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))

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

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