Sunteți pe pagina 1din 5

How to do a VLOOKUP in Excel

Excel vlookup is a very handy tool to compare data in two spreadsheets. Specifically, it can be used to import data from one spreadsheet to another for comparison purposes. A tip before you start: this is easier than it looks. Once you have mastered vlookup, you will find it a fast, easy tool to use for data analysis. Steps: Ensure that the data you are using to match is in the left column (column A) in both spreadsheets. An employee ID number is being used here as the key. Ensure that the data in the columns are values. If the data was produced from a reporting tool such as Query or Cognos Impromptu, it will be in text format. You may use the 'Value' formula in Excel to change the data from text to values. This is a very important step. If the data is not in a 'values' format, the lookup function will not work! To change text data to a value: Insert two blank columns in the spreadsheet, and type in '=value(A2)' , or use the formula wizard to bring up the value formula: Click on the grey '=' button , and then choose 'value' from the drop down menu. If you do not see 'value', click on 'More Functions', and search for 'value' in the 'All' category. You will find 'value' near the bottom, because the functions are listed alphabetically.

A dialogue box will appear and prompt you for the cell you want to change into a value:

Either click once with your mouse in the cell you want to change into a value, or just type in the value. (You can see the result already being displayed in the grey area of the box) Now click 'OK' to allow the formula to calculate.

Alice Pelkman University of Waterloo March 2001

Once you have changed the number into a value, you can copy the formula all the way down the column. You may use the edit, copy command, or just click on the edge of the cell and drag the formula down the column. To make the spreadsheet easier to work with, you may now remove the formulas, and just keep the resulting values. To change formulas to values, highlight the column with the formulas, click on 'copy'. Then click into the column where you want to paste the values and click on edit, paste special. (You may use either your menu bar, or right click on your mouse). Choose the paste special radio button 'values' to change the formulas into values.

Now you have three rows of the same data, but you only need one. Use edit, delete column, to remove the extra columns (columns A & B in this example). This will leave you with one column of values. Ensure that this column is column A when you are finished, or vlookup will not function properly. You may also want to rename the column you are saving with the appropriate title. Repeat the steps to change data to values for the other spreadsheet that you are working with.

Alice Pelkman University of Waterloo March 2001

Now that both spreadsheets are prepared, you may perform the actual vlookup. Steps: Open both spreadsheets in Excel. Some people prefer to split the screen, and view both spreadsheets at once, but others find this confusing, and use the Window command on the menu bar to move between the spreadsheets. Choose the spreadsheet you want to pull the values into and insert columns where you want the data to come in. In this example we are using data from the Production and Test environments and will pull the test results into the production spreadsheet. We will insert two columns for the lookup formula so that we can use copy and paste special to remove the formulas when we are finished. Note: where you place the extra columns is up to you and depends on the set up of the spreadsheets you are working with.

Now click in the first cell where you want to place the vlookup formula, click on the '=' sign and choose 'vlookup' from the drop down menu.

Alice Pelkman University of Waterloo March 2001

Click 'OK' and a dialogue box will appear where you can specify the lookup ranges and values.

Lookup_value: This is the value you want to look up, in this example it will be the employee ID, in column A. You may click in cell A2 to choose the data, or just type it into the box. Table_array: This is where you specify where you want to look up the comparison data. Because we are working with the Production data spreadsheet, the spreadsheet we are using for comparison is the Test data spreadsheet. The easiest way to fill this box is to click on 'Window' and choose the other spreadsheet. Then highlight the range you want to compare, or click in the blank grey box at the upper most left corner of the spreadsheet to highlight the entire sheet.

Alice Pelkman University of Waterloo March 2001

Col_index_num: This is the number of the column from your Test sheet that you want returned on your Production spreadsheet. In our example we want to retrieve the tax data column from our Test data spreadsheet and insert it into the column on our Production data sheet. This data is in column 'G' on our test sheet, which is the 7th column. So, we will type a '7' in this box. Please note that this may be a different column on the spreadsheet you are working with. Range_lookup: Type 'false' in this box for an exact data match. (Excel vlookup will return the next highest value in a range, unless you instruct it to return only an exact match.)

Now click 'OK' and the value you want will appear in your spreadsheet! Copy the formula all the way down the column and use the copy and paste special commands remove the formula and keep only the values. Congratulations - you did it. You will now wonder how you ever lived without vlookup!

Alice Pelkman University of Waterloo March 2001

S-ar putea să vă placă și