#1
|
|||
|
|||
Tough Excel Question
Suppose you have a spreadsheet where down the 1st column you have something like 1,1,1,1,2,2,2,2,3,3,3,3,etc. Down the 2nd column you have A,B,C,D,A,B,C,D,A,B,C,D,etc. Down the 3rd columnm you have 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, etc.
Is there a way to use the VLOOKUP function to input 2 variables, 1 from column 1 and 1 from column 2, to return the corresponding number in the 3rd column? The problem is that I can only figure out how to input 1 variable. So if I do a =VLOOKUP(2,A2:Cx,3,FALSE), then it only returns a 0.5 because that's the number in the 3rd column that corresponds to the first number 2 in the 1st column. If I wanted to return a 0.7, I'd need to input a 2 from the 1st column, AND a C from the 2nd column. Any ideas? |
#2
|
|||
|
|||
Re: Tough Excel Question
jeebus, that is a tough question!
|
#3
|
|||
|
|||
Re: Tough Excel Question
You could create a fourth column that is the combination of the first two and do a VLOOKUP on that column. Am I misunderstanding your question?
|
#4
|
|||
|
|||
Re: Tough Excel Question
[ QUOTE ]
You could create a fourth column that is the combination of the first two and do a VLOOKUP on that column. [/ QUOTE ] Yes. "&" is your friend. |
#5
|
|||
|
|||
Re: Tough Excel Question
[ QUOTE ]
You could create a fourth column that is the combination of the first two and do a VLOOKUP on that column. Am I misunderstanding your question? [/ QUOTE ] This is the correct answer. If for some reason you cannot manipulate the data, then you can get funky with array functions instead. But usually, you should just create a new column in front of your data table called ID or Index or Key or whatever and just concatenate the two columns that you want to look up. Then just look up the concatenation. |
#6
|
|||
|
|||
Re: Tough Excel Question
The key to your problem is to not arrange things into three colums, but do do an array like. Your first column would be the same, but your second, instead of a column would be a row.
IE, instead of this: 1 A x 2 B x 3 C x 4 D x 5 E x You'd have: A B C D E 1 x x x x x 2 x x x x x 3 x x x x x 4 x x x x x 5 x x x x x Forumla: =VLOOKUP(row#key, $table$table, MATCH(columnkey, $header$row:$range$x, 0), FALSE) http://www.techonthenet.com/excel/fo.../2d_lookup.php |
#7
|
|||
|
|||
Re: Tough Excel Question
That's a)a pain in the ass and b)going to mess up pivot tables that need it in the first format.
|
#8
|
|||
|
|||
Re: Tough Excel Question
Putting things in alphabetic columns like Excel does, you've got numbers in column A and letters in column B. Insert a column C that merges these two, so that cell C1=a1&b1. Then do your vlookup in column D on the value you desire from column C.
To create your lookup value, do the same thing, maybe in a row above the dataset. So insert 2 rows above all of your data. In cell A1, you will input the value from column A that you want. In cell B1, you will input the value from column B that you want. Cell C1 will = A1&B1. Your lookup formula will then reference C1. Or you can type the letter/number combination directly into the vlookup formula like you did in your example. Edit: obviously not fast enough |
#9
|
|||
|
|||
Re: Tough Excel Question
[ QUOTE ]
You could create a fourth column that is the combination of the first two and do a VLOOKUP on that column. Am I misunderstanding your question? [/ QUOTE ] And you have to sort the data by that column, I believe. |
#10
|
|||
|
|||
Re: Tough Excel Question
[ QUOTE ]
[ QUOTE ] You could create a fourth column that is the combination of the first two and do a VLOOKUP on that column. Am I misunderstanding your question? [/ QUOTE ] And you have to sort the data by that column, I believe. [/ QUOTE ] For a real vlookup, this is true. Which is why it is often preferable to use Index(DataColumn, Match(LookupValue, KeyColumn,0),false) instead of a true vlookup. The Index and Match functions are also more flexible than vlookups. |
|
|