INDIRECT / OFFSET in arrays?

yytsunamiyy

Well-known Member
Joined
Mar 17, 2008
Messages
963
This thread has trigegred a question regarding INDIRECT / OFFSET with me.

The OP is summing a non-continous range:

Code:
'[Master rota Term 6 2011.xls]Shift Requirements'!$C$5+'[Master rota Term 6 2011.xls]Shift Requirements'!$C$8+'[Master rota Term 6 2011.xls]Shift Requirements'!$C$11+'[Master rota Term 6 2011.xls]Shift Requirements'!$C$14+'[Master rota Term 6 2011.xls]Shift Requirements'!$C$17+'[Master rota Term 6 2011.xls]Shift Requirements'!$C$20+'[Master rota Term 6 2011.xls]Shift Requirements'!$C$23+'[Master rota Term 6 2011.xls]Shift Requirements'!$C$29:$C$30

I was wondering if it is possible to build an array for summing that non-continous range without having to repeat '[Master rota Term 6 2011.xls]Shift Requirements'! for each cell in the range.

I was thinking along the lines of
Code:
=SUM (or sumprodukt) (INDIRECT("'[Master rota Term 6 2011.xls]Shift Requirements'!$C$"&{ROW(A5),ROW(A8),ROW(A11),ROW(A14),ROW(A17),ROW(A20),ROW(A23),ROW(A29),ROW(A30)})

or alternativly:

Code:
=SUM (or sumprodukt) (OFFSET('[Master rota Term 6 2011.xls]Shift Requirements'!$C$5,{0,3,6,9,12,15,18,24,25},{0,0,0,0,0,0,0,0,0},{1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1})

Neither of which i got to work - not even as an array (CSE) formula. Why not and is there a way to do this?
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
This thread has trigegred a question regarding INDIRECT / OFFSET with me.

The OP is summing a non-continous range:

Code:
'[Master rota Term 6 2011.xls]Shift Requirements'!$C$5+
'[Master rota Term 6 2011.xls]Shift Requirements'!$C$8+
'[Master rota Term 6 2011.xls]Shift Requirements'!$C$11+
'[Master rota Term 6 2011.xls]Shift Requirements'!$C$14+
'[Master rota Term 6 2011.xls]Shift Requirements'!$C$17+
'[Master rota Term 6 2011.xls]Shift Requirements'!$C$20+
'[Master rota Term 6 2011.xls]Shift Requirements'!$C$23+
'[Master rota Term 6 2011.xls]Shift Requirements'!$C$29:$C$30

I was wondering if it is possible to build an array for summing that non-continous range without having to repeat '[Master rota Term 6 2011.xls]Shift Requirements'! for each cell in the range.

I was thinking along the lines of
Code:
=SUM (or sumprodukt) 
(INDIRECT("'[Master rota Term 6 2011.xls]Shift Requirements'!$C$"&
{ROW(A5),ROW(A8),ROW(A11),ROW(A14),ROW(A17),ROW(A20),
ROW(A23),ROW(A29),ROW(A30)})

or alternativly:

Code:
=SUM (or sumprodukt) 
(OFFSET('[Master rota Term 6 2011.xls]Shift Requirements'!$C$5,{0,3,6,9,12,15,18,24,25},
{0,0,0,0,0,0,0,0,0},
{1,1,1,1,1,1,1,1,1},{1,1,1,1,1,1,1,1,1})

Neither of which i got to work - not even as an array (CSE) formula. Why not and is there a way to do this?

How about?...
Rich (BB code):
=SUM(
  SUMPRODUCT(--(MOD(ROW(X!$C$5:$C$23)-ROW(X!$C$5),3)=0,X!$C$5:$C$23),
   X!$C$29:$C$30)

where X should replaced with:

'[Master rota Term 6 2011.xls]Shift Requirements'
 
Upvote 0
Interesting solution Aladin. I take it that INDIRECT / OFFSET don't accept arrays then?

They would be a pain with closed books. Moreover, specifying a set of cells for INDIRECT does not follow a generic pattern. For example,

=SUM(N(INDIRECT({"A2","C5","F2"})))

requires us to spell out in hard-code what is needed.
 
Upvote 0
I see. So, apart from the closed wb problem of INDIRECT,
Code:
=SUM(N(INDIRECT({"X!A2","X!C5","X!F2"})))
would work, but would
Code:
=SUM(N(INDIRECT("X!"&{"A2","C5","F2"})))
work too?

(can't test myself at the mo, only open office here :mad:)
 
Upvote 0

Forum statistics

Threads
1,224,561
Messages
6,179,521
Members
452,923
Latest member
JackiG

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top