Conditional Vlookup

uk

Board Regular
Joined
Nov 4, 2003
Messages
101
I am trying to put together a vlookup that works on 2 criteria matching before returning the result, I have been playing around with some of the logical functions but no luck as yet.

Here is an example of what I am trying to do

You have a table of values:

a--4--mick
g--7--john
k--6--fred
a--9--peter
h--0--tom
k--2--paul

You want the vlookup to return the name where the first column = a and the second column =9, in this case the answer would be Peter.

Any ideas?
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
One way of doing this would be to concatenate the first two columns and then use the result of that for the lookup.

eg

<TABLE BORDER CELLSPACING=1 CELLPADDING=9 WIDTH=394>
<TR><TD WIDTH="8%" VALIGN="TOP" BGCOLOR="#ffffff">TD>
<TD WIDTH="23%" VALIGN="TOP" BGCOLOR="#ffffff">
<FONT FACE="Arial" SIZE=3>A</FONT></TD>
<TD WIDTH="23%" VALIGN="TOP" BGCOLOR="#ffffff">
<FONT FACE="Arial" SIZE=3>B</FONT></TD>
<TD WIDTH="23%" VALIGN="TOP" BGCOLOR="#ffffff">
<FONT FACE="Arial" SIZE=3>C</FONT></TD>
<TD WIDTH="23%" VALIGN="TOP" BGCOLOR="#ffffff">
<FONT FACE="Arial" SIZE=3>D</FONT></TD>
</TR>
<TR><TD WIDTH="8%" VALIGN="TOP" BGCOLOR="#ffffff">
<FONT FACE="Arial" SIZE=3>1</FONT></TD>
<TD WIDTH="23%" VALIGN="TOP">
<FONT FACE="Arial" SIZE=3>a4</FONT></TD>
<TD WIDTH="23%" VALIGN="TOP">
<FONT FACE="Arial" SIZE=3>a</FONT></TD>
<TD WIDTH="23%" VALIGN="TOP">
<FONT FACE="Arial" SIZE=3>4</FONT></TD>
<TD WIDTH="23%" VALIGN="TOP">
<FONT FACE="Arial" SIZE=3>mick</FONT></TD>
</TR>
<TR><TD WIDTH="8%" VALIGN="TOP" BGCOLOR="#ffffff">
<FONT FACE="Arial" SIZE=3>2</FONT></TD>
<TD WIDTH="23%" VALIGN="TOP">
<FONT FACE="Arial" SIZE=3>g7</FONT></TD>
<TD WIDTH="23%" VALIGN="TOP">
<FONT FACE="Arial" SIZE=3>g</FONT></TD>
<TD WIDTH="23%" VALIGN="TOP">
<FONT FACE="Arial" SIZE=3>7</FONT></TD>
<TD WIDTH="23%" VALIGN="TOP">
<FONT FACE="Arial" SIZE=3>john</FONT></TD>
</TR>
<TR><TD WIDTH="8%" VALIGN="TOP" BGCOLOR="#ffffff">
<FONT FACE="Arial" SIZE=3>3</FONT></TD>
<TD WIDTH="23%" VALIGN="TOP">
<FONT FACE="Arial" SIZE=3>k6</FONT></TD>
<TD WIDTH="23%" VALIGN="TOP">
<FONT FACE="Arial" SIZE=3>k</FONT></TD>
<TD WIDTH="23%" VALIGN="TOP">
<FONT FACE="Arial" SIZE=3>6</FONT></TD>
<TD WIDTH="23%" VALIGN="TOP">
<FONT FACE="Arial" SIZE=3>fred</FONT></TD>
</TR>
<TR><TD WIDTH="8%" VALIGN="TOP" BGCOLOR="#ffffff">
<FONT FACE="Arial" SIZE=3>4</FONT></TD>
<TD WIDTH="23%" VALIGN="TOP">
<FONT FACE="Arial" SIZE=3>a9</FONT></TD>
<TD WIDTH="23%" VALIGN="TOP">
<FONT FACE="Arial" SIZE=3>a</FONT></TD>
<TD WIDTH="23%" VALIGN="TOP">
<FONT FACE="Arial" SIZE=3>9</FONT></TD>
<TD WIDTH="23%" VALIGN="TOP">
<FONT FACE="Arial" SIZE=3>peter</FONT></TD>
</TR>
<TR><TD WIDTH="8%" VALIGN="TOP" BGCOLOR="#ffffff">
<FONT FACE="Arial" SIZE=3>5</FONT></TD>
<TD WIDTH="23%" VALIGN="TOP">
<FONT FACE="Arial" SIZE=3>h0</FONT></TD>
<TD WIDTH="23%" VALIGN="TOP">
<FONT FACE="Arial" SIZE=3>h</FONT></TD>
<TD WIDTH="23%" VALIGN="TOP">
<FONT FACE="Arial" SIZE=3>0</FONT></TD>
<TD WIDTH="23%" VALIGN="TOP">
<FONT FACE="Arial" SIZE=3>tom</FONT></TD>
</TR>
<TR><TD WIDTH="8%" VALIGN="TOP" BGCOLOR="#ffffff">
<FONT FACE="Arial" SIZE=3>6</FONT></TD>
<TD WIDTH="23%" VALIGN="TOP">
<FONT FACE="Arial" SIZE=3>k2</FONT></TD>
<TD WIDTH="23%" VALIGN="TOP">
<FONT FACE="Arial" SIZE=3>k</FONT></TD>
<TD WIDTH="23%" VALIGN="TOP">
<FONT FACE="Arial" SIZE=3>2</FONT></TD>
<TD WIDTH="23%" VALIGN="TOP">
<FONT FACE="Arial" SIZE=3>paul</FONT></TD>
</TR>
</TABLE>
 
Upvote 0
Book2
ABCDEFGH
1XYZConcat
2a4micka4a9peter
3g7johng7
4k6fredk6
5a9petera9
6h0tomh0
7k2paulk2
8
9
Sheet1


Formulas...

D2, copied down:

=A2&CHAR(127)&B2

H2:

=INDEX($C$2:$C$7,MATCH(F2&CHAR(127)&G2,$D$2:$D$7,0))
 
Upvote 0
Been using the formula as it works great except for one thing, if the value does not appear in the range then it Returns #N/A which is really annoying because I use the reults of the formula on a calculation which wont work if #N/A is returned, anybody know a way round this?
 
Upvote 0
uk said:
Been using the formula as it works great except for one thing, if the value does not appear in the range then it Returns #N/A which is really annoying because I use the reults of the formula on a calculation which wont work if #N/A is returned, anybody know a way round this?

Fearing that you don't want a 2-cell approach (using an additional cell)...

=IF(ISNUMBER(MATCH(F2&CHAR(127)&G2,$D$2:$D$7,0)),INDEX($C$2:$C$7,MATCH(F2&CHAR(127)&G2,$D$2:$D$7,0)),"")

A 2-cell approach:

I2:

=MATCH(F2&CHAR(127)&G2,$D$2:$D$7,0)

H2:

=IF(ISNUMBER(I2),INDEX($C$2:$C$7,I2),"")

which is the result cell.
 
Upvote 0

Forum statistics

Threads
1,216,033
Messages
6,128,427
Members
449,450
Latest member
gunars

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top