Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

2 Answers

up vote 8 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
add comment

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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.