Questions tagged [vlookup]

VLOOKUP is a Spreadsheet function for retrieving a value from an array using a vertical lookup value and a positive column offset. Use with [excel-formula] or [google-sheets-formula] or any other product that supports such lookup

VLOOKUP is a Spreadsheet function for retrieving a value from a table array using a lookup value and a column offset.

There are four arguments to the VLOOKUP function:

  1. lookup_value - the value being searched for. This value must be located in the leftmost column of the table array in order to return a result.
  2. table_array - a range or array of values being searched for the lookup value. This argument can be a range (ex: A1:D10) or a text array (ex: {"ABC","DEF"}).
  3. col_index_num - a number setting the column of the array from which the corresponding value to be returned from the corresponding row that the lookup value is obtained from.
  4. range_lookup - TRUE or FALSE (or their numeric equivalents of 1 or 0) respectively) indicating whether the lookup is for an exact match, or closest value to the lookup value sorted in ascending order. This argument can also be a cell reference (which may contain a formula) which returns one of the above values.

It may be used on the worksheet as well as in by calling the Application.WorksheetFunction.VLookup Function or just Application.VLookup.

Related Tags:


Links:

Issues with VLOOKUP are often from one or more of the following causes:

  1. Attempting to “look to the left” – see emboldened text at 1. above. A col_index_num of 0 or less returns #VALUE! and the range for the table_array cannot be reversed within the formula (D10:A1 is treated as A1:D10). Solutions here may be to rearrange the columns (by either copying, ie a ‘helper column’, or moving the lookup_value column to the left) or to apply the INDEX/MATCH combination instead (example).

  2. Seeking a value that is not in the table_array, probably returning #N/A, or Error 2042 in VBA. Formatting (a text ‘1’ is not the same as a numeric 1) and trailing spaces, for example, may give the appearance that a lookup_value exists in the table_array when it does not. A simple way to check for this is to copy the search value onto the position in the table_array where a match is expected.

  3. Seeking a value that is outside the table_array range. This can happen when a VLOOKUP formula is copied down that refers to a stacked (columnar) range to be searched that is not an entire column and that has not been anchored (set with $s preceding row numbers) or defined as a Named Range. (example (for COUNTIFS)).

  4. Applying the wrong col_index_num, which is one-based. With a table_array, of say a column of numbers on the left and colour names immediately to the right, to return a colour name based on a lookup_value that is a number then the relevant col_index_num is 2.

  5. Failing to add 0 (or FALSE) as the fourth parameter. range_lookup is optional and defaults to TRUE (or 1) if not specified. This makes the assumption that the table_array is sorted in ascending order and applies a binary search for speed and efficiency. Where the fourth parameter for VLOOKUP is not specified and the table_array is not sorted in ascending order an incorrect result, but often plausible in appearance, is very probable.

VLOOKUP does not provide an all results of lookup in a array. If, for example, various shades of red were all assigned the same numeric code in the table_array a numeric lookup_value would, at most, find only one instance (the first, say ‘pink’). Sometimes this may be resolved to find a single result (but say ‘scarlet’ instead of ‘pink’) with a concatenated field in the table_array, and creation of a ‘key’ to suit. (example). Another case where this approach may suit is if there are several different people with the same surname - so the key might be to combine surname with a first name.

4398 questions
54
votes
4 answers

Remove #N/A in vlookup result

How do I modify this function so that the result will merely be a blank cell rather than having #N/A show up if B2 has nothing in that cell? I think I might need something like an ISERROR check but I don't 100% know what I'm…
office-rat
  • 575
  • 2
  • 5
  • 7
45
votes
3 answers

vlookup in Pandas using join

I have the following 2 dataframes Example1 sku loc flag 122 61 True 123 61 True 113 62 True 122 62 True 123 62 False 122 63 False 301 63 True Example2 sku dept 113 a 122 b 123 b 301 c I want to perform a merge, or join opertation…
Alex Kinman
  • 2,437
  • 8
  • 32
  • 51
25
votes
1 answer

Excel VLOOKUP where the key is not in the first column

"The range where the lookup value is located. Remember that the lookup value should always be in the first column in the range for VLOOKUP to work correctly. For example, if your lookup value is in cell C2 then your range should start with C." But…
BrianFreud
  • 7,094
  • 6
  • 33
  • 50
23
votes
4 answers

How to optimize vlookup for high search count ? (alternatives to VLOOKUP)

I am looking for alternatives to vlookup, with improved performance within the context of interest. The context is the following: I have a data set of {key;data} which is big (~ 100'000 records) I want to perform a lot of VLOOKUP operations on the…
d-stroyer
  • 2,638
  • 2
  • 19
  • 31
21
votes
1 answer

Check if an excel cell exists on another worksheet in a column - and return the contents of a different column

What I want to do is to say if the contents of cell D3 (on current worksheet) exist in column A in the first worksheet (in my case entitled list). (and they always do exist somewhere). Return the contents of the corresponding row in Column C. In…
YelizavetaYR
  • 1,611
  • 6
  • 21
  • 37
21
votes
2 answers

Excel - find cell with same value in another worksheet and enter the value to the left of it

I have a report that is generated in Excel which contains an employee's number, but not his/her name. Not every employee will be on this worksheet on any given day. In a 2nd worksheet I have a list of all employees' numbers and names. I want a…
Nicole Smith
  • 219
  • 1
  • 2
  • 3
19
votes
3 answers

"Unable to get the VLookup property of the WorksheetFunction Class" error

I am trying to develop a form to track invoices as they come in. The form will have a combobox where I can click on and select a vendor number. I want the textbox to automatically fill in based on the vendor number selected from the combobox. …
user2864307
  • 191
  • 1
  • 1
  • 3
17
votes
1 answer

Filling down a VLOOKUP formula without changing the range

I am comparing values in a row in one sheet to values in another row in another sheet. The following formula and works: =IFERROR(VLOOKUP(A1,Sheet1!A1:A19240,1,FALSE),"No Match") My problem is when I fill down the formula, it increments A1…
Andrew
  • 343
  • 1
  • 3
  • 9
17
votes
7 answers

Vlookup referring to table data in a different sheet

I would like to use a VLOOKUP function referring to a data table placed in a different sheet from the one where the VLOOKUP function in written. Example: in Sheet 1, cell AA3 I would like to insert the VLOOKUP function. I want the function to check…
Gianluca
  • 6,307
  • 19
  • 44
  • 65
15
votes
2 answers

Excel vba - convert string to number

So, I used the left function to take the first 4 characters of a string and I need to run a vlookup with it, but it won't find the match because it's looking through numbers. I want to do this in a macro, so I'm not sure about the syntax. Can…
user960358
  • 295
  • 3
  • 6
  • 14
15
votes
2 answers

Lookup using table with separated columns

I would like to use VLOOKUP() using a table input consisting of columns that are not next to each other. Example MyCell = VLOOKUP(A1, MyTable, 2, FALSE) MyTable = B1:B10 and D1:D10 Is there a way of making this operation work using a lookup…
karamell
  • 713
  • 7
  • 16
  • 28
15
votes
4 answers

Way to overcome Excel Vlookup function limit of 256 characters

I have a excel array with multiple values. Some are less than 256 characters and some have a length greater than 256. When I tried to do a VLookup using a sample string, I can get results when it matches the rows with less than 256 characters. For…
sandyiit
  • 1,597
  • 3
  • 17
  • 23
14
votes
4 answers

Python - function similar to VLOOKUP (Excel)

i am trying to join two data frames but cannot get my head around the possibilities Python has to offer. First dataframe: ID MODEL REQUESTS ORDERS 1 Golf 123 4 2 Passat 34 5 3 Model 3 500 8 4 M3 5 0 Second…
Christian
  • 241
  • 1
  • 3
  • 8
14
votes
3 answers

How to inner-join in Excel (eg. using VLOOKUP)

Is there a way to inner join two different Excel spreadsheets using VLOOKUP? In SQL, I would do it this way: SELECT id, name FROM Sheet1 INNER JOIN Sheet2 ON Sheet1.id = Sheet2.id; Sheet1: +----+------+ | ID | Name | +----+------+ | 1 | A | | …
Wabbage
  • 437
  • 3
  • 6
  • 18
12
votes
2 answers

Excel VBA: Can't get a match, error "Unable to get the Match property of the WorksheetFunction class"

For the love of all that is good, I cannot seem to get this to work. I keep getting the error mentioned above. I have this table, and I'm trying to find out whether the code matches it's own sub-code somewhere within the other column, however it's…
Humble Val
  • 379
  • 2
  • 8
  • 17
1
2 3
99 100