You are here:

Excel/linked a variable cell values to other worksheet

Advertisement


Question
hi,

is it possible to link a variable cell value to other worksheet inside the function VLOOKUP? for example inside a VLOOKUP, VLOOKUP(A1, $E$4!$A$1:$B4$4,2, TRUE), where $E$4 stands for the name of the other worksheet that is gonna to be linked to. From my understanding the $E$4 format is wrong. May I know the correct method to link them?

Answer
Weichao,

If you mean the the cell $E$4 holds the name of the sheet where the range A1:B4 is located, (for example, E4 holds the value Sheet5) then


=VLOOKUP(A1,Indirect($E$4&"!$A$1:$B$4"),2,TRUE)

this would produce the equivalent of


=VLOOKUP(A1,Sheet5!$A$1:$B$4,2,TRUE)

but, as you asked, you can make the name of the sheet variable by changing it in cell E4

If the sheet name will have a space in it, then it needs to be enclosed in single quotes


so if E4 held the sheet name:  Data Base
and you had a sheet named  Data Base

then
=VLOOKUP(A1,Indirect("'"&$E$4&"'!$A$1:$B$4"),2,TRUE)

would be equivalent to

=VLOOKUP(A1,'Data Base'!$A$1:$B$4,2,TRUE)


the indirect worksheet function will convert a valid string to a range reference - including a reference to a range on another sheet if your string is written that way.

Is that what you were looking for?

--
Regards,
Tom Ogilvy  
About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here

Excel

All Answers


Answers by Expert:


Ask Experts

Volunteer


Tom Ogilvy

Expertise

Selected as an Excel MVP by Microsoft since 1999. Answering Excel questions in Allexperts since its inception in 2001. Able to answer questions on almost all aspects of Excel's internal capabilities. If seeking a VBA solution, please specify that in your question itself so I give you the answer you want. [Excel has weak protection - if you are distributing an application, I don't answer questions on how to protect your project from your users.]

Experience

Extensive experience.

Education/Credentials
Master of Science (MS) degree Operations Research (ORSA)

Awards and Honors
Microsoft MVP in Excel.

©2016 About.com. All rights reserved.