sam
sam

Reputation: 10094

Reference a variable value in another cell as part of formula

SHORT QUESTION

Ive got a formula =IF(ISBLANK(Q.1!C71),"",Q.1!C71) im trying to be able to set a control cell / variable so instead of C71 it would reference c*$B$1*, *$B$1* being my reference / control cell / variable in the same sheet as this formula, any ideas how to do this ?


LONG QUESTION

Ive got a spreadsheet that is regularly provided by a 3rd part with different data in it each time, although the column order of the data is always the same.

To get the data into my spreadsheet, i create another tab in the same workbook as their sheet and reference the data in their spreadsheet in a sheet i call import template sheet, i then from there copy and paste the import sheet into my spreadsheet, as all the columns match.

To reorder their columns in a non destructive way i use the following formula in my import template sheet, for instance if i wanted their column C, in my sheets column F i would place this in F1 and the pull the cell down so it does this for all rows :

=IF(ISBLANK(Q.1!C71),"",Q.1!C71) (the ifblank just helps sanitise the data by not throwing #ref if there is no data in the cell.)

The issue i have is that i have around 30 columns to re order and although the column structure is the same, there is sometimes some 'header' data (basically a text summary) at the top of the document of varying length, so instead of the first row i need being 71 sometimes it might be row 50 or row 90...

To speed things up id like to be able to have a control number / variable cell where i can set a variable for the starting row, and then reference that in my cell, so that i dont have the go and edit the formula in 30 different columns.

Upvotes: 0

Views: 3655

Answers (1)

Rob Wise
Rob Wise

Reputation: 5120

If you want to control the starting row of the reference by putting a number in cell B1, that would look something like this:

B1

71

Referencing Cell

=IF(ISBLANK(INDIRECT("Q.1!C"&B1),"",INDIRECT("Q.1!C"&B1))

INDIRECT allows you to build a string representation of a cell reference and then get the value of that cell. So we build a string reference using the value of B1, and then use INDIRECT to get the value of that string's referenced cell.

Upvotes: 1

Related Questions