Reputation: 21
Say I have 9 reference cells in one column which each have a corresponding value in the next column as seen below:
Alpha 1
Beta 2
Gamma 3
Delta 4
Epsilon 5
Zeta 6
Eta 7
Theta 8
Iota 9
I would like to use VLOOKUP or LOOKUP to enter the reference cell, and return the corresponding value. For example if 'Alpha' was typed in cell A1, and the above two columns were in B and C I would use =LOOKUP(A1, $B$1:$B$9, $C$1:$C$9). Which should return 1. However, if I do this for all nine cells, I get the following results instead:
1
2
7
2
5
9
7
8
7
I get the same results whether I am using =LOOKUP with two separate vectors or one array, or if I use =VLOOKUP.
Any insight on why this is happening would be appreciated.
Upvotes: 1
Views: 22914
Reputation: 1716
Just need to use =VLOOKUP(A1,$B$1:$C$9,2,FALSE)
Always use FALSE
(or 0
) inside the formula. I use FALSE
most of the time inside the formula because most of the time the data is not sorted, BUT if you already know your data is sorted, you can use TRUE
.
Remember:
=VLOOKUP({a},{b},{c},{d})
a=
lookup_value Required. The value to search in the first column of the table or range. The lookup_value argument can be a value or a reference. If the value you supply for the lookup_value argument is smaller than the smallest value in the first column of the table_array argument, VLOOKUP returns the #N/A error value.
b =
table_array Required. The range of cells that contains the data. You can use a reference to a range (for example, A2:D8), or a range name. The values in the first column of table_array are the values searched by lookup_value. These values can be text, numbers, or logical values. Uppercase and lowercase text are equivalent.
c =
col_index_num Required. The column number in the table_array argument from which the matching value must be returned. A col_index_num argument of 1 returns the value in the first column in table_array; a col_index_num of 2 returns the value in the second column in table_array, and so on.
d =
range_lookup Optional. A logical value that specifies whether you want VLOOKUP to find an exact match or an approximate match: 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.
For more information, see Sort data in a range or table.
If range_lookup is FALSE, the values in the first column of table_array do not need to be sorted.
If the range_lookup argument is FALSE, VLOOKUP will find only an exact match. If there are two or more values in the first column of table_array that match the lookup_value, the first value found is used. If an exact match is not found, the error value #N/A is returned.
For short:
=VLOOKUP({a},{b},{c},{d})
a = You want to find this
b = You want to find inside this
c = you want to return this column, Always a integer, and always is >1 and <total of columns of c
d = User FALSE or 0 if you have a unsorted list/data, and use TRUE if you ALREADY KNOW your data is sorted.
Upvotes: 3