BrentSmits
New Member
- Joined
- Nov 21, 2018
- Messages
- 4
Hello
I would like to know where my logic is faulty since Excel returns or 0 or #VALUE as a result.
I would like to transfer the following in a formula using INDIRECT and ADRES:
=SUM(T9:Y9*T6:Y6)
Some additional details:
The column letter can be created using indirect itself (row number, column number) or can be created using substitute(adres(...)). I tried both, but that didn't give me the result I wanted.
The problem seems to appear with the * element used for multiplying the rows.
Multiplying 2 sums using indirect works perfectly:
SUM(INDIRECT(SUBSTITUTE(ADDRESS(1;COLUMN(T9);4);1;"")&ROW(T9)&":"&SUBSTITUTE(ADDRESS(1;COLUMN(T9)+$S9-1;4);1;"")&ROW(T9)))*SUM(INDIRECT(SUBSTITUTE(ADDRESS(1;COLUMN(T$6);4);1;"")&ROW(T$6)&":"&SUBSTITUTE(ADDRESS(1;COLUMN(T$6)+$S9-1;4);1;"")&ROW(T$6)))
This is the same as: SUM(T9:Y9)*SUM(T6:Y6) and I can easely change the Y to X or U or V or ... depending on my needs.
Why do I need to use this?
I have calculated a value that tells me how many datapoints I need to use. If I need 6 datapoints (all of them), I could just use the array without INDIRECT but sometimes I need 5 datapoints or 4 or 3 or ... so I would like to calculate the cell reference (T9:Y9) is 6 cells for example.
It is really just this annoying * that doesn't do multiplying.
The following returns 0 (not using indirect) if you would like to test (just plug in values at cells T6:Y6 and then plug in numbers at cells T9:Y9 or any other line but this last numbers need to change all the time so you have to use $ at T6:Y6 if you use this in the formula):
=SUM(SUBSTITUTE(ADDRESS(1;COLUMN(T9);4);1;"")&ROW(T9)&":"&SUBSTITUTE(ADDRESS(1;COLUMN(T9)+$S9-1;4);1;"")&ROW(T9)&"*"&SUBSTITUTE(ADDRESS(1;COLUMN(T$6);4);1;"")&ROW(T$6)&":"&SUBSTITUTE(ADDRESS(1;COLUMN(T$6)+$S9-1;4);1;"")&ROW(T$6))
Using indirect gives me #VALUE
Even =SUM(INDIRECT(T9:Y9*T6:Y6)) gives me error (ctrl shift enter)
*The solution to this is ofcourse to use a SUMPRODUCT formula but I'm interested why this doesn't work as I see it. I want to know if I can improve my logic or learn something fundamental based on what I am doing so if you can make it work without SUMPRODUCT, please don't hesitate to do so, if it can't be solved, please explain what happens within my formula or why it can't work*
Thanks in advance!!!
I would like to know where my logic is faulty since Excel returns or 0 or #VALUE as a result.
I would like to transfer the following in a formula using INDIRECT and ADRES:
=SUM(T9:Y9*T6:Y6)
Some additional details:
The column letter can be created using indirect itself (row number, column number) or can be created using substitute(adres(...)). I tried both, but that didn't give me the result I wanted.
The problem seems to appear with the * element used for multiplying the rows.
Multiplying 2 sums using indirect works perfectly:
SUM(INDIRECT(SUBSTITUTE(ADDRESS(1;COLUMN(T9);4);1;"")&ROW(T9)&":"&SUBSTITUTE(ADDRESS(1;COLUMN(T9)+$S9-1;4);1;"")&ROW(T9)))*SUM(INDIRECT(SUBSTITUTE(ADDRESS(1;COLUMN(T$6);4);1;"")&ROW(T$6)&":"&SUBSTITUTE(ADDRESS(1;COLUMN(T$6)+$S9-1;4);1;"")&ROW(T$6)))
This is the same as: SUM(T9:Y9)*SUM(T6:Y6) and I can easely change the Y to X or U or V or ... depending on my needs.
Why do I need to use this?
I have calculated a value that tells me how many datapoints I need to use. If I need 6 datapoints (all of them), I could just use the array without INDIRECT but sometimes I need 5 datapoints or 4 or 3 or ... so I would like to calculate the cell reference (T9:Y9) is 6 cells for example.
It is really just this annoying * that doesn't do multiplying.
The following returns 0 (not using indirect) if you would like to test (just plug in values at cells T6:Y6 and then plug in numbers at cells T9:Y9 or any other line but this last numbers need to change all the time so you have to use $ at T6:Y6 if you use this in the formula):
=SUM(SUBSTITUTE(ADDRESS(1;COLUMN(T9);4);1;"")&ROW(T9)&":"&SUBSTITUTE(ADDRESS(1;COLUMN(T9)+$S9-1;4);1;"")&ROW(T9)&"*"&SUBSTITUTE(ADDRESS(1;COLUMN(T$6);4);1;"")&ROW(T$6)&":"&SUBSTITUTE(ADDRESS(1;COLUMN(T$6)+$S9-1;4);1;"")&ROW(T$6))
Using indirect gives me #VALUE
Even =SUM(INDIRECT(T9:Y9*T6:Y6)) gives me error (ctrl shift enter)
*The solution to this is ofcourse to use a SUMPRODUCT formula but I'm interested why this doesn't work as I see it. I want to know if I can improve my logic or learn something fundamental based on what I am doing so if you can make it work without SUMPRODUCT, please don't hesitate to do so, if it can't be solved, please explain what happens within my formula or why it can't work*
Thanks in advance!!!