简体   繁体   中英

Dynamically referencing cells in other worksheets in Excel?

I have a table of data, a selection of which look like:

BARC    0.0001  0.0003  0.0006  0.0012  0.0009  0.0010  0.0008  0.0024
BNP     0.1915  4.1915  0.2314  0.3147  0.3168  0.3300  0.3060  0.4277
CSGN    0.1915  0.0003  0.2221  0.0104  0.0109  0.0124  0.0097  0.0152

The data in each cell are linked to a separate worksheet which share a name with the names in the first column. Each entry in the table for each column references the same cell but in a different worksheet. So B1 is BARC!G850, B2 is BNP!G850, and B3 IS CSGN!G850. The references are the same for each cell besides the worksheet name, but they don't increase incrementally across the rows; C1 IS BARC!G858 and D1 is BARC!G863, for example.

I want to use a formula to automatically populate the table instead of typing out the worksheet name references by hand. How can I do this?

Use the formula =INDIRECT($A1 & "!G850") and copy that down column 1. For other columns you use the respective cell reference.

You can make it a bit more dynamic to include a row at the top in which you specify the exact cell reference to use in the formula for each column.

The formula should then read something like =INDIRECT($A1 & "!" & B$1) This will allow you to simply copy the same formula to all cells and it will use the sheet name from the first column and the cell reference at the top to lookup the correct cell from the correct worksheet

Using the INDIRECT function you can reference a worksheet based on the text in ColA.

 A    | B                      | C
 BARC | =INDIRECT( A1&"!G850") | =INDIRECT( A1&"!G858")

etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM