Wednesday, December 21, 2011

Ms-Excel Lookup() function …What you must know?

Today while working on a excel template I learned a very interesting thing about Excel Lookup () function.

Excel Lookup function is used to find or return value from a range or array. The range could be a row or column or set of rows and columns. The entire syntax is like this:

=LOOKUP(lookup_value,lookup_vector,result_vector)

Just like we store data in SQL Server tables we can store the data in a tabular format in Ms-Excel. I had following data in my excel sheet.

I had another sheet which had customer name and their details. I had to fill up the Continent column using Lookup () function.

I applied the Lookup() function on column F like this

=LOOKUP(E3,Sheet1!$B$4:$B$10,Sheet1!$C$4:$C$10)

and the result was like this

As you can see the result was not as I expected. The result is showing incorrect Continents. How come UK is in America and India in Europe? This is not right Mr. Excel

I did some finding to fix this issue and while fixing this issue I came to a very interested point that is

“The RANGE you use in Lookup function must be sorted i.e. in ascending order”

I sorted the sheet1 data and all my results in sheet 2 got corrected.

This was interesting to know while dealing with Lookup you should be careful with the range you are using. Your RANE must be sorted to give you the right result.

Popular Posts

Real Time Web Analytics