# INDIRECT with two array RSQ formula

#### runway9r

##### New Member
Hi everyone
I am trying to write a dynamic RSQ equation where some of the arguments are called in by the INDIRECT function. I have no problem using INDIRECT with a one array function (like sum), for example,

(1/H7)*SUM(INDIRECT("E"&H3&":E"&H4))

but I can't get this to work with 2.

So the basic equation is: =RSQ(A:B, X:Y), where A,B,X,Y are cell references.

(i) Term A will always be fixed at the actual cell \$E\$8
(ii) What I need term B to be is \$E\$Variable 1 (where variable 1, the row number, will always be in cell A4 -- but changes frequently depending on what I am doing)

(iii) Term X: here the column will change as I go across the spreadsheet (F, G, H, I, etc.), but the row number will always start with 8.

(iv) Y will also have the same column (F, G, H, I, etc.) as X, but the row number to go along with it has to be the number in cell 4.

Here is what I tried: =RSQ(INDIRECT("\$E\$8"&":\$E\$"&\$A\$4&",G\$8"&":G"&\$A\$4))

Thanks for any suggestions.

### Excel Facts

Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

#### shg

##### MrExcel MVP

=RSQ(\$E\$8:INDEX(\$E:\$E, \$A\$4), F\$8:INDEX(F:F, \$A\$4))

#### runway9r

##### New Member

=RSQ(\$E\$8:INDEX(\$E:\$E, \$A\$4), F\$8:INDEX(F:F, \$A\$4))

shg: I truly hope I can help you out some day. But after my first few days participating in this forum, I am pretty sure it won't be with excel. Obviously, thanks - I get stuck thinking I am going at the problem the right way and don't always see the bigger set of options. Works like a charm.

#### shg

##### MrExcel MVP
Code:
``... I am pretty sure it won't be with excel.``
Thank you.

It actually could be written using INDIRECT, but INDIRECT is intrinsically volatile, so I avoid it unless there's no other way.

#### runway9r

##### New Member

Code:
``... I am pretty sure it won't be with excel.``
Thank you.

It actually could be written using INDIRECT, but INDIRECT is intrinsically volatile, so I avoid it unless there's no other way.

When you have a chance and feel like it, could you explain what and why it is volitile?

#### shg

##### MrExcel MVP
Maybe "intrinsically" is too strong a word.

If A1 contains the text B1:B4, then the formula

=SUM(INDIRECT(A1))

... returns the sum of B1:B4. Excel can see that the formula depends on the contents of A1, but not on B1:B4. You could argue that Excel should be able to, but it would be very complex for the general case. For example, the value in A1 could itself be the result of a formula, e.g., ="B1:B" & SUM(C1:C3)

So Excel punts and recalculates the formula any time it calculates anything.

Prefer to avoid the use of OFFSET in favor of INDEX for the same reason.

Last edited:

#### runway9r

##### New Member
Maybe "intrinsically" is too strong a word.

If A1 contains the text B1:B4, then the formula

=SUM(INDIRECT(A1))

... returns the sum of B1:B4. Excel can see that the formula depends on the contents of A1, but not on B1:B4. You could argue that Excel should be able to, but it would be very complex for the general case. For example, the value in A1 could itself be the result of a formula, e.g., ="B1:B" & SUM(C1:C3)

So Excel punts and recalculates the formula any time it calculates anything.

Prefer to avoid the use of OFFSET in favor of INDEX for the same reason.

Thanks, got it. - Looks like this week's learning goal will be to better develop my skills with INDEX !

Replies
2
Views
113
Replies
8
Views
98
Replies
12
Views
116
Replies
1
Views
71
Replies
11
Views
93