Two Plus Two Older Archives  

Go Back   Two Plus Two Older Archives > 2+2 Communities > Other Other Topics
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 08-18-2005, 04:14 PM
LondonBroil LondonBroil is offline
Senior Member
 
Join Date: Jan 2003
Posts: 576
Default 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?
Reply With Quote
  #2  
Old 08-18-2005, 04:21 PM
cbfair cbfair is offline
Senior Member
 
Join Date: Sep 2004
Posts: 206
Default Re: Tough Excel Question

jeebus, that is a tough question!
Reply With Quote
  #3  
Old 08-18-2005, 04:24 PM
davelin davelin is offline
Senior Member
 
Join Date: Aug 2004
Posts: 708
Default 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?
Reply With Quote
  #4  
Old 08-18-2005, 04:25 PM
Soul Daddy Soul Daddy is offline
Senior Member
 
Join Date: Oct 2004
Location: Hurricanes, animal corpses and your potential new tattoo have a lot in common. Think about it.
Posts: 463
Default 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.
Reply With Quote
  #5  
Old 08-18-2005, 04:26 PM
TheWorstPlayer TheWorstPlayer is offline
Senior Member
 
Join Date: Dec 2004
Location: Boring work = post too much
Posts: 2,435
Default 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.
Reply With Quote
  #6  
Old 08-18-2005, 04:26 PM
icepick icepick is offline
Junior Member
 
Join Date: Apr 2004
Posts: 0
Default 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
Reply With Quote
  #7  
Old 08-18-2005, 04:28 PM
TheWorstPlayer TheWorstPlayer is offline
Senior Member
 
Join Date: Dec 2004
Location: Boring work = post too much
Posts: 2,435
Default 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.
Reply With Quote
  #8  
Old 08-18-2005, 04:29 PM
FatOtt FatOtt is offline
Junior Member
 
Join Date: Sep 2002
Posts: 11
Default 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
Reply With Quote
  #9  
Old 08-18-2005, 04:31 PM
maryfield48 maryfield48 is offline
Senior Member
 
Join Date: May 2004
Location: Kingston, Jamaica
Posts: 144
Default 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.
Reply With Quote
  #10  
Old 08-18-2005, 04:35 PM
TheWorstPlayer TheWorstPlayer is offline
Senior Member
 
Join Date: Dec 2004
Location: Boring work = post too much
Posts: 2,435
Default 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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:00 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.