Monday, January 21, 2013

Intricacies of VLOOKUP

In Microsoft Excel, VLOOKUP is a very useful function that "searches for a value in the first column of a table array and returns a value in the same row from another column in the table array." The basic syntax of the function is =VLOOKUP(lookup_value, table_array, col_index_num, range_lookup), with the range_lookup being optional.

If range_lookup is FALSE, the function will look for only exact matches. In this case, the values in the first column of table_array do not need to be sorted. However, this is not the case if range_lookup is TRUE, which is the selection by default if omitted. Then the values in the first column must be in ascending order, as the function will use the largest value smaller than the lookup_value, if an exact match is not found.

Finally, two wildcard characters allow flexibility in the lookup_value when it is a text and the range_lookup is FALSE. A question mark (?) matches any single character, while asterisk (*) matches any sequence of characters. Use a tilde (~) before either the question mark or asterisk if they are the actual characters in the lookup_value. So as an example, the text value "abc" can be matched by both "a??" and "a*".

Source: