Search code examples
excelexcel-formulavlookupexcel-2013worksheet-function

How to input two arrays in VLOOKUP?


I have a worksheet in Excel 2013 with two sheets: Sheet 1 and Sheet 2. I am applying a formula in both the sheets in the same column (G). The data is in more than 100,000 rows that's why I can't put it in one sheet only.

The problem is that I want to use VLOOKUP in both sheets in a way that the function looks up in both sheets in the same columns (arrays) i.e. A and B columns in sheet 1 and sheet 2 and get the value from column B i.e. column 2 within VLOOKUP function.

How can I add reference to the other sheet?


Solution

  • I doubt a complete solution is possible with VLOOKUP because, for instance, the corresponding ColumnB values may differ even where a ColumnA value is the same on both sheets. So without VBA (or possibly merging your sheets) you may have to compromise, so I offer only a partial solution, based on Excel 2007.

    This 'looks up' in the 'other' sheet and only defaults to the 'same' sheet where the first attempt is unsuccessful. It uses INDEX and MATCH because likely quicker than VLOOKUP for high volumes. The formula I have applied for Sheet1 (in G1 and to be copied down) is:

    =IFERROR(INDEX(Sheet2!B$1:B$6,MATCH(E1,TwoArray,0)),INDEX(B$1:B$7,MATCH(E1,OneArray,0)))  
    

    where the OneArray and TwoArray are named ranges for parts of ColumnA for the two sheets and the link values are expected in ColumnE (the formula in Sheet2 is similar):

    SO18279006 example