Hello all -
I am trying to do the following:
Sheet 1 contains:
Item Sheet 2
ABC =vlookup(A2,'Sheet 2'!$A:$B,2,false)
Sheet 2 contains:
Item Data
ABC 2
I'm trying to get the vlookup to return the value "2"
Right now, I'm manually entering the tab name in the vlookup function, even though it's contained in cell B1.
The tabs are contained in the same workbook if that matters. Since this workbook is growing rather quickly, this is a painful process and doesn't feel very scalable. Since I'm using a mac, I need to do this with functions vs. macros. Does anybody know how I can reference a cell for the name of a tab in the vlookup function?
I was thinking I could maybe somehow do this with the INDIRECT function but I'm stumped.
I apologize if this wasn't clear but it seems to be a slightly convoluted question.
Thanks in advance for the help.
Last edited by gabem; 05-27-2009 at 03:19 PM.
Does your sheet2 tab really have a space in it? Sheet 2? That's not standard, and spaces in sheettabs make these formulas a little more confusing to look at....consider NOT having spaces.
INDIRECT is the function you want.
Without spaces in the tab name:
=VLOOKUP(A2,INDIRECT($B$1&"!$A:$B"),2,FALSE)
With spaces in the tab name:
=VLOOKUP(A2,INDIRECT("'"&$B$1&"'!$A:$B"),2,FALSE)
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
“None of us is as good as all of us” - Ray Kroc
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
THANK YOU!!!!
I was just using it incorrectly. This should save me some time.
INDIRECT() used this way constructs a normal reference but does it one piece at a time. All the components have to be represented within the INDIRECT() brackets to resolve a normal cell or range reference.
==============
If that takes care of your need, be sure to EDIT your original post (Go Advanced) and mark the PREFIX box [SOLVED].
(Also, use the "scales" icon in our posts to leave Feedback, it is appreciated)
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
“None of us is as good as all of us” - Ray Kroc
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks