Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.newusers
ben ben is offline
external usenet poster
 
Posts: 22
Default vlookup with 2 columns?

Hello,

I am doing a VLOOKUP which is working nicely, but I had this idea where the
user could specify in the sheet data from 1 column and then data from
another column and where you have both in the row I would get other data in
the row. Is there anyway of doing that?

E.g. if the data was like I have laid out below and the user specified A1
and X2 I could get at the data 20 or 21 but I wouldn't want the row before that.
A1 X1 10 11
A1 X2 20 21
B1 Y1 11 22
B2 Y2 22 33

Thanks.
Bn
  #2   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 15,768
Default vlookup with 2 columns?

If the data to return is numeric as is demonstrated in your sample *and* the
combination of A1+X2 is unique:

=SUMPRODUCT(--(A1:A4="A1"),--(B1:B4="X2"),C1:C4)

Or, this generic version works for any data type.

Array entered** :

=INDEX(C1:C4,MATCH(1,(A1:A4="A1")*(B1:B4="X2"),0))

** array formulas need to be entered using the key combination of
CTRL,SHIFT,ENTER (not just ENTER)

--
Biff
Microsoft Excel MVP


"ben" wrote in message
...
Hello,

I am doing a VLOOKUP which is working nicely, but I had this idea where
the user could specify in the sheet data from 1 column and then data from
another column and where you have both in the row I would get other data
in the row. Is there anyway of doing that?

E.g. if the data was like I have laid out below and the user specified A1
and X2 I could get at the data 20 or 21 but I wouldn't want the row before
that.
A1 X1 10 11
A1 X2 20 21
B1 Y1 11 22
B2 Y2 22 33
Thanks.
Bn



  #3   Report Post  
Posted to microsoft.public.excel.newusers
ben ben is offline
external usenet poster
 
Posts: 22
Default vlookup with 2 columns?

So far I have just been experimenting with the first option and it works. I
am not familiar enough with the notation to know why though. A1:A4 and B1:B4
define the range (array) of cells I want checked and putting the array = to
something implies a condition matching the cell I want. What does the '--'
before the condition mean? From what I read on SUMPRODUCT each array needs
to be the same size, but I would have thought that the below example may
have them not being the same size unless the '--' has something to do with
it. Would you be able to clarify this for me?

Thanks,
Bn

T. Valko wrote:
If the data to return is numeric as is demonstrated in your sample *and* the
combination of A1+X2 is unique:

=SUMPRODUCT(--(A1:A4="A1"),--(B1:B4="X2"),C1:C4)

Or, this generic version works for any data type.

Array entered** :

=INDEX(C1:C4,MATCH(1,(A1:A4="A1")*(B1:B4="X2"),0))

** array formulas need to be entered using the key combination of
CTRL,SHIFT,ENTER (not just ENTER)

  #4   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 2,420
Default vlookup with 2 columns?

Take a look at this

http://tinyurl.com/6bc2yt

--
__________________________________
HTH

Bob

"ben" wrote in message
...
So far I have just been experimenting with the first option and it works.
I am not familiar enough with the notation to know why though. A1:A4 and
B1:B4 define the range (array) of cells I want checked and putting the
array = to something implies a condition matching the cell I want. What
does the '--' before the condition mean? From what I read on SUMPRODUCT
each array needs to be the same size, but I would have thought that the
below example may have them not being the same size unless the '--' has
something to do with it. Would you be able to clarify this for me?

Thanks,
Bn

T. Valko wrote:
If the data to return is numeric as is demonstrated in your sample *and*
the combination of A1+X2 is unique:

=SUMPRODUCT(--(A1:A4="A1"),--(B1:B4="X2"),C1:C4)

Or, this generic version works for any data type.

Array entered** :

=INDEX(C1:C4,MATCH(1,(A1:A4="A1")*(B1:B4="X2"),0))

** array formulas need to be entered using the key combination of
CTRL,SHIFT,ENTER (not just ENTER)




  #5   Report Post  
Posted to microsoft.public.excel.newusers
ben ben is offline
external usenet poster
 
Posts: 22
Default vlookup with 2 columns?

Thanks!

Bob Phillips wrote:
Take a look at this

http://tinyurl.com/6bc2yt

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sum columns up to vlookup value Sinkguy1 Excel Worksheet Functions 3 April 1st 08 09:51 PM
VLOOKUP using 2 columns Humphrey Excel Discussion (Misc queries) 2 January 4th 08 11:05 AM
VLookup in to columns Frederik Excel Worksheet Functions 2 October 26th 06 08:48 PM
VLookup against one of two columns Mark Excel Worksheet Functions 2 March 13th 06 04:38 PM
Vlookup using two columns Daniel Bonallack Excel Worksheet Functions 3 December 9th 05 07:02 PM


All times are GMT +1. The time now is 02:50 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"