问题
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