Dynamic cell reference in formula that points to another tab

atf32

Board Regular
Joined
Apr 13, 2011
Messages
157
I have a simple formula in cell A1 that points to a cell on a different sheet ("=Sheet3!J4"). However, need to change this to make is more dynamic. For instance, I need the actual cell reference part (J4) to be more dynamic. So in some cases I may want to pass a different row. How can I write this formula so that I can pass a different row in it, to pick the data in a different row? :confused:
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
You can use the INDIRECT function to dynamically build your range reference.
Let's say that you are putting the row number in cell A1. Then you could write your formula like this:
Code:
=INDIRECT("Sheet3!J" & A1)
 
Upvote 0
The simplest way is to use the OFFSET function.
If in A2 you have the number of rows you may want to move, use the formula in A1:
=OFFSET(Sheet3!J4,A2,0)
By default it will be 0. If you want J6, enter 2 in A2 and it will return that value.

Have a google on help for OFFSET. It's a very powerful function, a lot of people aren't happy about it for (IMHO) overly technical reasons. But I use it all the time, and have done for 15+ years
 
Upvote 0
Another way is to use a 'Dynamic name'. Press ctrl-F3 to bring the name manager up.

Give it a name, MyCell for e.g. Then in the refers to box, put "=OFFSET(Sheet3!J4,Sheet1!A2,0)"

Then in any sheet, you can type =MyCell and it will bring the value from Sheet3 based on what is in Sheet1.

Where this becomes very useful, say you wanted to always bring the last item in a vertical list. Say Sheet3 colj J could have any number of items below J4 (with no blanks, that's important), and you always wanted the last 1.

In the Name Manager call the name 'LastItem' and in the refers to box you would enter "=OFFSET(Sheet3!J4,COUNTA(Sheet3!J4:J1000000),0)"
Then on any sheet if you wanted the last item you would type =LastItem.
and as long as there were no blanks and the last item wasn't below row 1,000,000 it would bring back the last item. If you wanted the last but 1 item, the refers to would contain
"=OFFSET(Sheet3!J4,COUNTA(Sheet3!J4:J1000000)-1,0)"
And so on, there's a world of possibilities with 'dynamic range names'.
 
Upvote 0
This is exactly what I was looking for. Earlier, I wasn't using the Indirect correctly. Thanks for the help and the quick response.:)
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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