Sumproduct check if text is name of a named range and return those numbers

只愿长相守 提交于 2020-01-24 19:30:28

问题


the user is able to enter either a number or a name into a cell. When i put a number, sumproduct is working fine, but when i want it to check if the name of a named range is inside the cell, it doesn't return anything.

=SUMPRODUCT((Data!A:A=A7)*((Data!C:C=V7)+(Data!C:C=W7)),Data!H:H)

Data!A:A is an accountnumber and Data!C:C is the countryID. Data!H:H is the sales that need to be added up.

I have a few named ranges with number attached to them

  • FirstRange: 4, 12, 15
  • SecondRange: 7, 38, 65

How can I check inside my sumproduct if the cell has a named range and then apply that named range array to be summed up?


回答1:


As per my understanding, you currently have two named ranges:

As per your screenshot, it looks like you are looking for this Array formula (enter it with Ctrl+Shift+Enter):

=SUMPRODUCT(--($M$2:$M$13=A2),--IF(ISNUMBER(B2),($N$2:$N$13=B2),ISNUMBER(MATCH($N$2:$N$13,INDIRECT(B2),0))),$O$2:$O$13)

See the results below - I have added a color-coding in column A and columns P-S to show how the formula works (i.e. which rows are being included / excluded into the SUMPRODUCT calculation):



来源:https://stackoverflow.com/questions/59681314/sumproduct-check-if-text-is-name-of-a-named-range-and-return-those-numbers

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