Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to create a VLOOKUP formula in excel, however, the table array may be in a number of different worksheets.

For example, I have this forumula

=Vlookup(a1, ‘[Datafile.xlsx]worksheetapples’!$A1:F500,3,False)

This works fine in a single scenario, but worksheetapples isn't my only worksheet that I want to do a lookup from, I have worksheetbananas and worksheetpears

Is there a way to pass in the worksheet to reference?

EDIT: I'm trying to avoid having to write an IF formula which checks a value and then uses the relevant VLOOKUP. It would be much easier to pass in the name of the worksheet rather than check if A1 is apples, do VLOOKUP on apples, if A1 is pears then do lookup on pears etc

share|improve this question
up vote 9 down vote accepted

Try using INDIRECT, as in

=Vlookup(a1, INDIRECT(CONCATENATE("‘[Datafile.xlsx]",B1,"'!$A1:F500")),3,False)

where B1 contains the sheet name.

share|improve this answer

Use INDIRECT function. For example, put [Datafile.xlsx]worksheetapples’!$A1:$A10 as text in A1 and =SUM(INDIRECT(A1)) in A2. Check what it happens to A2 value!

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .