4

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

2 Answers 2

9

Try using INDIRECT, as in

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

where B1 contains the sheet name.

0

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!

You must log in to answer this question.

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