Question

Here is a sample table:

         A          B           
1        animal     value       
2        dog        brown          
3        cat        black 

In another sheet cell A1 is a drop down list of all animals in the above column A. What is the formula for this pseudo code to calculate what value goes in A2 in the other sheet:

If A1 (in the other sheet) equals dog, A2 (in the other sheet) equals the value directly to the right of dog in the sample table (brown)

If A1 (in the other sheet) equals cat, A2 (in the other sheet) equals the value directly to the right of cat in the sample table (black)

and so on...

Was it helpful?

Solution

VLOOKUP(lookup_value,table_array,col_index_num,range_lookup) is the pseudocode you are looking for. For this specific question the below code should work:

=VLOOKUP(A1,Sheet1!A:B,2,0)

Explanation of components:
lookup_value: value to search in the first column of the array
table_array: the range of cells in which the table exists. the first column of this table is what is looked for by lookup_value
col_index_num: the column in the table in which to search, 1 = first column, 2 = 2nd column
range_lookup: used for testing of exact matches or approximate matches

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top