I realised that when I wrote the ISNA function article that I had never written an explanation of VLOOKUP. I want to write up explanations for a umber of other functions in the future like COLUMN, ROW, MATCH and INDEX followed by OFFSET. All these make lots of sense when you use them with the VLOOKUP function. So I though it best to start with this function. I will also say that everything I write about VLOOKUP here applies to HLOOKUP as well. the only difference is the orientation, that is VLOOKUP looks across columns from left to right, and HLOOKUP looks down rows from top to bottom.
The built in Excel Help is very good at helping with this function. However it doesn't point out many of the pitfalls than occur in common use.
The VLOOKUP function syntax has the following arguments (argument: A value that provides information to an action, an event, a method, a property, a function, or a procedure.):
If the col_index_num argument is:
- Less than 1, VLOOKUP returns the #VALUE! error value.
- Greater than the number of columns in table_array, VLOOKUP returns the #REF! error value.
If range_lookup is either TRUE or is omitted, an exact or approximate match is returned. If an exact match is not found, the next largest value that is less than lookup_value is returned.
Important: If range_lookup is either TRUE or is omitted, the values in the first column of table_array must be placed in ascending sort order; otherwise, VLOOKUP might not return the correct value.
If range_lookup is FALSE, the values in the first column of table_array do not need to be sorted.
Common Uses of VLOOKUP.
I use VLOOKUP frequently – many times a day and in many different ways. While I am aware that there are limitations to how it works (more on these soon) in the following circumstances it performs well.
Example: I have 2 columns of the same data from two spreadsheets – different versions or different data sources. I want to know if all the data is in both spreadsheets, and if not which data is missing from which sheet. Typical scenarios include account codes from an accounting system, names from a payroll system, lists of suppliers or customers, lists of gas wells from a an engineers data collection sheet etc.
The data may be several hundred or thousand lines long – and it is not time efficient or practical to scroll up and down the two lists comparing them. Sorting them doesn’t necessarily work, and if there are duplicates then looking at the total number in each list isn’t going to help.
Solution: I would copy and paste the two columns of data into column A of two separate sheets in a temporary work book (or maybe work with it in the source files and delete my work afterwards). IMPORTANT: I would then sort each list in ascending order.
In column B of Sheet1 I would make a formula like so: =VLOOKUP(A1,Sheet2!$A:$A,1,FALSE). After filling this down for each item in column A It is very easy to filter out all the #N/A items. These are the items that do not appear in column A of Sheet2.
In Sheet2 Column B I would write a formula like so: =VLOOKUP(A1,Sheet1!$A:$A,1,FALSE). After filling this down for each item in column A It is very easy to filter out all the #N/A items. These are the items that do not appear in column A of Sheet1.
Example: I am trying to balance a set of data that is being summarised from a source set using SUMIF formulas to group the data into some top level values. The sum of these subtotals should equal the sum of the original data.
Eg RAW Sales data totals compared with the sum of the sales data by Salesman suing the SUMIF formula does not equal for some reason. I have checked and every line of raw data has a salesman’s name against it and each unique salesman’s name is being included in the subtotals. Or so I think. In actual fact there is a typo and there are some sales mans names that have an extra space after the name, or maybe a couple of letters transposed. This is a very common error and not easily located in a set of data of several thousand rows. (see a previous post about this problem)
Solution: Assume the salesman’s names from the raw set of data are in column A of Sheet1 and the sales values are in column B. Column C is blank. Column A of Sheet2 is the subtotals of salesman’s names (appearing once) with the SUMIF subtotals in column B.
In column C of Sheet1 I would enter a formula that compares the salesman’s name from column A against the subtotal page on Sheet2 like so:=VLOOKUP(A1,Sheet2!$A:$A,1,FALSE). Once again after filling down for all the data in the raw data sheet, I can filter on this column and any #N/A values will highlight the problems – spelling mistakes, extra spaces, etc.
That’s enough for this week. Next week I will continue on with more on VLOOKUP and HLOOKUP – more scenarios of day to day use of them, and some of the common traps, including why sorting is important.
Comments
Dear sir, Thanks for your
Dear sir,
Thanks for your information about Vlookup instruction.
but I have a question about this instruction , I have two columns that compound
of two rows make key for searching.
can I use of thses two columns for "vlookup" . the the first part vlookup instruction 'values '.
your early answer will be highly appreciated.
Thanks and best regards.
If I understand your question
If I understand your question correctly you want to find the result when searching using criteria from 2 columns not just one.
this is not possible using the vlookup function or the match or index function either.
It needs to be performed using sum product or an array function.
check out bobs website for that http://www.xldynamic.com/source/xld.SUMPRODUCT.html
also this might be helpful http://www.spyjournal.biz/node/475
I have a spreadsheet that I
I have a spreadsheet that I am trying to use the HLOOKUP function with. Basically I have created a pricelist where I have a list of suppliers at the top of the table (D4:K4) and a list of products along the side of the page (B5:B173). Through the middle, obviously are the different prices from all of the different suppliers.
On this page, I have used conditional formatting so that the cheapest price from each item is formatted green.
My problem is this. I have created a second spreadsheet where I have copied the list of products from column B.
Column C on the second spreadsheet will contain the minimum value for that item or row extracted from the first page (using the =MIN function).
What I then want to do is place the supplier name in column C. I have tried to use the HLOOKUP function for this using the following formula: =HLOOKUP(D4,'Price Comparison'!D6:K6,4,('Price Comparison'!D4:K4))
What the formula returns is #VALUE. I am assuming this is because the HLOOKUP function does not return text? When I go through the evaluation process it says the following =HLOOKUP(3.9,'Price Comparison'!D6:K6,4,Wellington)
(3.9 being the minimum value from that row and Wellington being the supplier in the title row) So I am assuming that it is almost working, yes?
How do I get that cell to return Wellington as the result of the function?
Hi Josh complex sounding
Hi Josh
complex sounding problem
Do you want to send me the spreadsheets - or a sample that recreates your problem? I'm having difficulties visualizing it.
Cheers
My work demands the use of
My work demands the use of Vlookup function and now I can use it easily. Thanks for simplified information.
Hi I have two excel files and
Hi
I have two excel files and one "Raw" file and other "Validated" file. I am extracting the data from SQL database to raw file which is linked with validated excel file.
Now, I have to generate the data everyday. The validated excel file has column divided into different date columns.
My query is working fine but results goes to only dedicated column of validated excel file. What I want is to generate the report each day and I want excel to publish the data in the validated excel file date wise (Column Wise). I want to keep the old data as well. I mean data should go to the next column everyday from Raw file because raw file is generated everyday.
Query: =IF(ISNA(VLOOKUP(C3,'W PC LAB GUARD SAFETY CAB.xls'!Results,2,FALSE)),"",(VLOOKUP(C3,'W PC LAB GUARD SAFETY CAB.xls'!
Please help me...
I don't know whether I made myself clear.. but I need help, Please
regards
Imran
i think I know what you want
i think I know what you want Imran. However best to email me directly and we can talk though your problem and the best solution to it.
Cheers
Hi, thanks for explanation!
Hi, thanks for explanation! This tutorial also helped me much to understand how vlookup works:
http://www.myhowtoos.com/en/excel-howtoos/84-how-to-match-values-in-exce...
Dear Sir/Mam I want to know
Dear Sir/Mam
I want to know how we can create full employee master in excel file by vlookup function.
show result like:-
put the emp no. & get full information for that employee.
Hi Aakash The solution when
Hi Aakash
The solution when using a table with all the details you are wanting to find and then use vlookup is to make sure you have a unique identifier in the first column. This could be a employee number as you suggest.
So the table would be emp no, last name, first name, etc
the vlookup would focus on the emp no and then return the column you are looking for.
the best way to make that happen is to use a match function on the column heading to return the index no of the column and use that as the column no in the vlookup function.
hope this helps
Hello, I need help, I have
Hello,
I need help, I have a spread sheet with title on top and on the side numbers.
I need a formula that will look at the spread sheet and bring the exact amount for that line..
Example:
Items A1 A2 MRB Floor
XXXXX 54 200 20 500
need to take in consideration the Title on top then look for the item
Please help thanks
i am afraid i need more
i am afraid i need more detail and a little clearer explanation to help you. you can try emailing me the spreadsheet with what you are trying to do if you like.
tim at spyjournal dot biz.
Cheers
Post new comment