Skip to main content

Tutorial on Vlookup function for Excel

A quick notes on Vlookup Excel formula.

Vlookup formula is quite useful to find and locate data on Excel.

Table below will be used on how to demonstrate and use vlookup. But this basic idea is the same way you can apply even on a complicated or huge amount of excel data.

First we examine the parameters of Vlookup.

By typing Vlookup formula on Excel, Excel will prompt or display the parameters needed to complete the function.

Let's try to simplify or use lay man terms for the vlookup parameters.

In Excel 2007 that I'm using it displays these parameters below when I type Vlookup formula :

=Vlookup (look_up_value, table_array,col_index_num, [range_lookup])

The look_up_value is indeed the value that you're looking for or the data you're trying to find.

The table_array is the range of cells, or basically the whole cells or columns in which the data will be search.

The col_index_num, is the data that will be returned once the look_up_value matches any data define on the table_array.

The [range_lookup], let's just put a FALSE value on it to find the Exact Match.

Now that we know the parameters for the vlookup function, will use it to find some data on our example table below.

Sample Table Vlookup Demo
A Column (Column 1) B Column (Column 2) C Column (Column 3)
Asset Number Description Owner
ABC-123 Laptop John
ABC-456 Desktop Kim
ABC-789 Ipad Thomas
ABC-1122 Laptop Martin
ABC-1455 Desktop Paul
ABC-1788 Ipad Matthew
ABC-2121 Laptop Jude
ABC-2454 Android Augustine
ABC-2787 Ipad Francis
ABC-3120 Laptop Jude
ABC-3453 Desktop Joachim
ABC-3786 Android Anthony
ABC-4119 Laptop Alfonso
ABC-4452 Desktop Lorenzo
ABC-4785 Android Pedro
ABC-5118 Laptop Michael
ABC-5451 Desktop Gabriel
ABC-5784 Android James
ABC-6117 Laptop Peter

Let's say we know the asset number and we want to check who's the owner of it.

So in vlookup function, since we have the asset number it will be a good start to find some other data.

Vlookup function formula will be constructed like this:

=Vlookup(A11,A2:C20,3,False) will return Jude

=Vlookup(A12,A2:C20,3,False) will return Joachim

Let's examine the formula, the "A11" is the look up value for Asset Number ABC-3120, the "A2:C20" is the range of cells and column for the search area, the number "3" means return the value if the exact match is found, three columns from the look up value. First column is Asset Number, second column is Description, third column is Owner. Then the last parameter is "False" which tells vlookup to find for the exact match.

Now let's check the second vlookup formula, the value of "A12" is the look up value, A2:C20 is the search range area, number "3" is to return the value from the third column "Owner" if the exact match is found.

If the column index number in the vlookup formula was set to "2", then the second column labeled as "Description" will be the returned value for the vlookup.

You can try changing the vlookup formula to =Vlookup(A12, A2:C20,2,False), you will notice that returned value will be "Desktop", it is because you define on the formula, if there is an exact match get the value from second column.

You can try to experiment, changing the column index number and the look up value, but don't change the search range (don't change the search range if you copy the same table from this example) and don't change also the False parameter.

Vlookup is very useful to find and search data, but it will generate errors such as "#NA" and “#REF", I know you've seen those errors a lot and your eyes will turn big and rolls when such error occurs.

To avoid such error, we need to know how vlookup search for data. Vlookup works from left to right only. Wait..what is left to right?

What I mean is, the look up value parameters on the vlookup formula is the point of reference.

What I mean by point of reference, if the look up value is under column A such as A11, A12 or any cells on column A, then the column index number will start from Column A, Column B, Column C and so on and so for.

To simplify this explanation, let's take our example from above table.

Column A is Asset Number (column index number 1), Column B is Description (column index number 2), Column C is Owner (column index number 3) Let's say we have this formula

=Vlookup(B2,B2:C20,2,False), this formula will return "Kim".

If we have this formula =Vlookup(B2,B2:C20,3,False), it will return a #REF! error.

Why it will return an error? The formula is not able to find any data on column index number 3 as define in vlookup.

But we have 3 columns and column 3 is Owner, as explained above the lookup value is under column B which is B2 on our example.

Since column B is our point of reference, that will be considered by vlookup as column 1. That's why the formula =Vlookup(B2,B2:C20,2,False) has no error and correct value is returned.

And this formula =Vlookup(B2,B2:C20,3,False), will have error since it is not able to find any data.

Okay, that is quite a mouthful for Vlookup function.

If still confused, make some comment and let’s discuss on that.

Here's more example below to add confusion.

A vlookup formula of:

=Vlookup(A12,A2:C20,3,FALSE)
Returned value is:
Joachim

=Vlookup(A12,A2:C20,2,FALSE)
Returned value is:
Desktop


=Vlookup(A14,A2:C20,3,FALSE)
Returned value is:
Alfonso

=Vlookup(A14,A2:C20,2,FALSE)
Returned value is:
Laptop


=Vlookup(A7,A2:C20,3,FALSE)
Returned value is:
Matthew

=Vlookup(A7,A2:C20,2,FALSE)
Returned value is:
Ipad


A vlookup formula of:
=Vlookup(B7,A2:C20,3,FALSE)
Will result to an error of: #N/A
Why there is an error?
Look up Value is B7.
and the search range is define as A2:C20


=Vlookup(B7,B2:C20,3,FALSE)
will result to an error of #REF!
Why there is an error?
range value is 3

There is another good function, which is Hlookup but how it works is almost the same as Vlookup.


Comments

Post a Comment

Popular posts from this blog

Notepad++ convert multiple lines to a single line and vice versa

Notepad++ is an awesome text editing tool, it can accept regex to process the text data. If the data is in a “.csv” format or comma separated values which is basically just a text file that can either be opened using a text editor, excel or even word. Notepad++ can process the contents of the file using regex. Example if the data has multiple rows or lines, and what is needed is to convert the whole lines of data into a single line. Notepad++ can easily do it using regex. However, if the data is on a single line and it needs to be converted into multiple lines or rows then regex can also be used for this case. Here’s an example on how to convert multiple rows or lines into a single line. Example data: Multiple rows, just a sample data. Press Ctrl+H, and  on "Find what" type: [\r\n]+ and on "Replace with" type with: , (white space) --white space is needed if need to have a space in between the data. See image below, "Regular Expression" must be se

WMIC get computer name

WMIC get computer model, manufacturer, computer name and  username. WMIC is a command-line tool and that can generate information about computer model, its manufacturer, its username and other informations depending on the parameters provided. Why would you need a command line tool if there’s a GUI to check? If you have 20 or 100 computers, or even more. It’s quite a big task just checking the GUI to check the computer model and username. If you have remote computers, you need to delegate someone in the remote office or location to check. Or you can just write a batch file or script to automate the task. Here’s the code below on how get computer model, manufacturer and the username. Open an elevated command prompt and type:     wmic computersystem get "Model","Manufacturer", "Name", "UserName" Just copy and paste the code above, the word “computersystem” does not need to be change to a computer name. A

How to check office version from command line

The are quite a few ways to check office version it can be done via registry, PowerShell or VBScript and of course, good old command line can also do it. Checking Windows office version whether it is Office 2010, Office, 2013, Office 2016 or other version is quite important to check compatibility of documents; or just a part of software inventory. For PowerShell this simple snippet can check the office version: $ol = New-Object -ComObject Excel.Application $ol . Version The command line option will tell you where’s the path located; the result will also tell whether office is 32-bit, 64-bit and of course the version of the office as well. Here’s the command that will check the office version and which program directory the file is located which will tell whether it’s 32-bit or 64-bit. Command to search for Excel.exe: DIR C:\ /s excel.exe | find   /i "Directory of"  Above command assumes that program files is on  C: drive. Sample Outpu