I keep thinking there must be a function that allows an address within a cell to be used as a variable within another cell address. For the types of sheets I’m creating it would make my life so much easier.
For the purposes of example, the function I seek is hypothetically called “THING” below:
Sheet1 Daily Menus
MONDAY MENU
Items: Helper Column Nutritional Data Results
A B C
1 =Sheet2!A35 =THING(A1,row=35) =INDIRECT("Sheet3!G"&B1) =Sheet3!G35
2 =Sheet2!A247 =THING(A2,row=247) =INDIRECT("Sheet3!G"&B2) =Sheet3!G247
3 =Sheet2!A989 =THING(A3,row=989) =INDIRECT("Sheet3!G"&B3) =Sheet3!G989
TUESDAY MENU
101 =Sheet2!A613 =THING(A101,row=613) =INDIRECT("Sheet3!G"&B101) =Sheet3!G613
The bottom line is:
In a complex spreadsheet (10 pages, each with hundreds of rows and columns), I want to manipulate the addresses by altering only the data in column A on page 1.
This would also allow me to easily copy column B down for hundreds of rows. The type of function in column B may also be required in columns C, D, E… for dozens or hundreds of columns.
Right now I’m typing in each needed address manually, or a very long function using the address. If anything changes in column A then I have to go back and retype these long functions… and often I find that I’ve made a typo with all that typing…
You seem to have as your starting point formula =Sheet2!A35
in cell A1.
What you have to do is:
-
Get the formula as a string.
For this you can use either XL4 macros, VBA, orFormulaText
(in Excel 2013 or later), see this. -
Extract the row number from the string.
For this you an use VBA (very easy), or a formula to find the rightmost letter/$
and keep the substring to its right. -
Use the previous answer, as you already incorporated in your question.
Answer to the first version of the question
I will split the formula you are looking for in two steps.
In cell B1 you can enter ="Sheet2!"&"X"&TEXT(A1,"0")
.
This will produce the result Sheet2!X25
.
Then in cell C1 you can enter =INDIRECT(B1)
.
This will bring into cell C1 the contents of cell Sheet2!X25
.
Notes:
-
You can copy the formula downwards as you need.
-
When copying into other columns, take care of relative/absolute indexing.
-
You could use a single formula (no helper column) in B1:
=INDIRECT("Sheet2!"&"X"&TEXT(A1,"0"))
. -
Both
Sheet2
and (column)X
could be replaced by suitable formulas if you want them not be hardcoded. -
Formula in B1 can almost certainly be replaced by
="Sheet2!"&"X"&A1
.
NB: A long time time ago, under circumstances I do not recall now, I found I needed to useTEXT
; YMMV.
Tags: excelexcel, function, sed