Office of Portfolio Analysis
OPA Excel Tips: Merging in data from another sheet (VLOOKUPs)
There are a number of situations where it is helpful to merge two datasets or copy a variable
from one dataset to another. The VLOOKUP function in Excel is a very handy way to do this.
A VLOOKUP looks for a specified value in an array of data (usually in another worksheet or
workbook), and returns the value from a specified column. (HLOOKUP is the same but looks for
rows)
The VLOOKUP command requires four pieces of information:
Look up value: The value you want to look up e.g. and Application ID. This is usual a cell
reference and changes for each line of the dataset. It is possible to look up any cell value
(text or numeric) but the method is most reliable when using an ID number as text (e.g.
institution name) may have different spellings or a space after the final letter for example.
These differences would prevent Excel from making the match.
It is also important to consider the two datasets you are using e.g. if there are multiple
rows per project number Excel will just copy across the value from the first match.
Table array: the dataset that you want to look to for the variable of interest. This needs to
include the value you are looking up in the leftmost column e.g. if you were looking up
based on ApplID, the first column of the array would need to contain ApplID. This doesn’t
need to be the first column on the worksheet though.
Column number: The number of the column in the array that contains the variable you are
interested in. This is independent of the number of columns in the spreadsheet e.g. if the
array you select is columns B to D and the variable is in column D, you would instruct the
VLOOKUP to use column 3.
Range lookup: Enter ‘false’ to ensure Excel searches for an exact match for the lookup
value.