Replace INDIRECT with INDEX to iterate closed work

2019-03-03 17:52发布

Yesterday I started a topic in regards of iterating cells from some workbooks into a new, summary workbook. For this I used INDIRECT function:

Iterate between workbooks using INDIRECT

However, realizing the backdrafts of INDIRECT I want to achieve the same thing, but by using INDEX, as I've read from forums that INDEX works even when the referenced workbook is closed, wheras INDIRECT does not.

Then, using

 =INDEX(CONCATENATE("'C:\Pathtofile\[";O282;"]";$O$283;"'!";ADDRESS(11;KOLUMN()-23));1)

Where O282 is the workbook I want to reference (which is referenced in this manner as I will need to iterate some workbooks like the workbook 2015-01 (O282), 2015-02 (P282) etc.) and O283 is the sheet of the corresponding workbook, which in this case is static. I want to import the value of cell D12 in the referenced workbook and worksheet with this, and actually the INDEX does this. ;1 is used to indicate that I only want to return 1 cell. (I believe US excel uses "," instead of ";").

The problem is though that it returns:

 'C:\Pathtofile\[2015-01]Data'!$D$11

so basically. INDEX references correct, but it returns the path and not the value which is intended.

EDIT:

I've tried:

 =INDEX(CONCATENATE("'C:\Pathtofile\[";O282;"]";$O$283;"'!";ADDRESS(11;KOLUMN()-23):ADRESS(12;KOLUMN()-23));1)

to get the Array D12:E12, and then reference to the value at the first referenced row, i.e. D12. This hasn't worked though, but it has been a way to avoid the problems associated with INDEX interpreting my input as a mean to return a reference, rather than a value.

1条回答
再贱就再见
2楼-- · 2019-03-03 18:38

INDEX, in your case, takes two arguments: reference and position. Instead of reference, you specified address, so Excel understands it as range with one value in it - which is your address and returns it to you. You should:

=INDEX(INDIRECT(CONCATENATE(...));1)

But as you use the first value in referenced range, you can simply do:

=INDIRECT(CONCATENATE(...))
查看更多
登录 后发表回答