Situation:
I am getting #Value!
when trying to pass the OFFSET
of a dynamic named range to SUMPRODUCT
.
Setup:
I have the following data in range A2:B4 of Sheet1.
| TextA | 1 |
|-------|---|
| TextA | 2 |
|-------|---|
| TextB | 3 |
I have created a dynamic named range, textRange
, of the values in column A with the formula:
=OFFSET(Sheet1!$A$2,0,0,COUNTA(Sheet1!$A$2:$A$1048576),1)
As shown in image:
Note: textRange
will pick up all required rows. It can be assumed to be pulled from a continuously populated range i.e. textRange covers all the rows required.
Aim:
I now want to Offset
from this, using the Column
function, to get the same rows 1 column across i.e. B2:B4
; and then sum the values in this range if the corresponding text in column A ends with "A".
The expected result would be 3.
Process:
1) I am using the following formula to construct the offset range:
OFFSET(A2,0,COLUMN(B1)-1,COUNTA(textRange),1)
The offset range could be any column after A, hence my use of Column
function so can drag formula across to return range of interest.
2) I then pass this Offset range to SUMPRODUCT and sum it's value if the corresponding Column A row has "A" as it's last letter i.e.
=SUMPRODUCT(OFFSET(A2,0,COLUMN(B1)-1,COUNTA(textRange),1),--(RIGHT(textRange,1)="A"))
Outcome:
The expected result would be 3
but is currently #Value!
Question:
What I am doing wrong? I am guessing it is because of how I am passing the range.
Requested solution:
I am open to any other way of achieving the same result. However, the formula must update the Offset for the dynamic range, when dragged across columns, and must perform the conditional sum on the new set of rows.
Reference:
https://chandoo.org/forum/threads/using-offset-function-with-sumproduct.960/
COUNTA
function and resultant text range can produce erroneous results if the data is not continuous betweenA2:A4
? Or will it be always continuous? – shrivallabha.redijCOLUMN(B1)-1
portion is failing the formula. AsCOLUMN(B1)
portion is returning an array of single element. – shrivallabha.redij