ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   VLOOKUP variable array references (https://www.excelbanter.com/excel-discussion-misc-queries/147642-vlookup-variable-array-references.html)

Simon

VLOOKUP variable array references
 
Wondering if in a VLOOKUP formula, when I refer to my array, I can refer to a
different worksheet than the one I'm in, with a cell in my current worksheet.
For example, my table array wouldn't be 'Scores'!A1:A5, it would be something
like 'B2'!A1:A5, where cell B2 carries the name of the worksheet I want to
refer to, and obviously varies. Thanks!
--
Simon

Elkar

VLOOKUP variable array references
 
Use the INDIRECT function.

=VLOOKUP(A1,INDIRECT("'"&B2&"'!A1:B100"),2,FALSE)

Note the use of both double and single quotes. Shown here with additional
spaces for emphasis: " ' " & B2 & " ' !

This allows for the use of spaces in your sheet name(s) stored in B2.

HTH,
Elkar


"Simon" wrote:

Wondering if in a VLOOKUP formula, when I refer to my array, I can refer to a
different worksheet than the one I'm in, with a cell in my current worksheet.
For example, my table array wouldn't be 'Scores'!A1:A5, it would be something
like 'B2'!A1:A5, where cell B2 carries the name of the worksheet I want to
refer to, and obviously varies. Thanks!
--
Simon



All times are GMT +1. The time now is 05:24 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com