Help needed - VLOOKUP based on IF statement, or similar

philobr

Active Member
Joined
Oct 17, 2005
Messages
276
Hi there,
I have a data set and Im trying to look up a specific value based on an initial look up in one column and then a secondary look up in another.

So data would look something like this:

A B C
Apples Granny Smyth 20
Apples Cooking 10
Apples Pink Lady 15


So based on the initial lookup of Apples, then a second lookup of Cooking to give me the total number.

Any help appreciated, thanks.
 

steve the fish

Well-known Member
Joined
Oct 20, 2009
Messages
7,823
Office Version
365
Platform
Windows
If you want a total sum or there is only one entry of each pair then:

=SUMIFS(C:C,A:A,"Apples",B:B,"Cooking")

Or if you just want the first hit:

=INDEX($C$1:$C$100,MATCH(1,INDEX(($A$1:$A$100="Apples")*($B$1:$B$100="Cooking"),0),0))

Or the last hit:

=LOOKUP(2,1/(($A$1:$A$100="Apples")*($B$1:$B$100="Cooking")),$C$1:$C$100)
 

AlanY

Well-known Member
Joined
Oct 30, 2014
Messages
3,979
Office Version
365, 2019, 2016
Platform
Windows
one way

<b></b><table cellpadding="2.5px" rules="all" style=";background-color: rgb(255,255,255);border: 1px solid;border-collapse: collapse; border-color: rgb(187,187,187)"><colgroup><col width="25px" style="background-color: rgb(218,231,245)" /><col /><col /><col /></colgroup><thead><tr style=" background-color: rgb(218,231,245);text-align: center;color: rgb(22,17,32)"><th></th><th>A</th><th>B</th><th>C</th></tr></thead><tbody><tr ><td style="color: rgb(22,17,32);text-align: center;">1</td><td style=";">Apples</td><td style=";">Granny Smyth</td><td style="text-align: right;;">20</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">2</td><td style=";">Apples</td><td style=";">Cooking</td><td style="text-align: right;;">10</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">3</td><td style=";">Apples</td><td style=";">Pink Lady</td><td style="text-align: right;;">15</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">4</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">5</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">6</td><td style=";">Apples</td><td style=";">Cooking</td><td style="text-align: right;background-color: #E2EFDA;;">10</td></tr></tbody></table><p style="width:5.6em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid rgb(187,187,187);border-top:none;text-align: center;background-color: rgb(218,231,245);color: rgb(22,17,32)">Sheet14</p><br /><br /><table width="85%" cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: rgb(255,255,255)" ><tr><td style="padding:6px" ><b>Worksheet Formulas</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: rgb(255,255,255);border-collapse: collapse; border-color: rgb(187,187,187)"><thead><tr style=" background-color: rgb(218,231,245);color: rgb(22,17,32)"><th width="10px">Cell</th><th style="text-align:left;padding-left:5px;">Formula</th></tr></thead><tbody><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">C6</th><td style="text-align:left">=SUMPRODUCT(<font color="Blue">--(<font color="Red">A1:A3=A6</font>),--(<font color="Red">B1:B3=B6</font>),C1:C3</font>)</td></tr></tbody></table></td></tr></table><br />
 

Special-K99

Well-known Member
Joined
Nov 7, 2006
Messages
8,328
=INDEX(C$1:C$3,MATCH(A6,IF(A$1:A$3=A$5,B$1:B$3),0),1)
Array formula, use Ctrl-Shift-Enter

Where A5 is Apples
and A6 is Cooking
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
33,646
Office Version
365
Platform
Windows
Something like
<b>Excel 2013/2016</b><table cellpadding="2.5px" rules="all" style=";background-color: rgb(255,255,255);border: 1px solid;border-collapse: collapse; border-color: rgb(187,187,187)"><colgroup><col width="25px" style="background-color: rgb(218,231,245)" /><col /><col /><col /><col /><col /></colgroup><thead><tr style=" background-color: rgb(218,231,245);text-align: center;color: rgb(22,17,32)"><th></th><th>A</th><th>B</th><th>C</th><th>D</th><th>E</th></tr></thead><tbody><tr ><td style="color: rgb(22,17,32);text-align: center;">2</td><td style=";">Apples</td><td style=";">Granny Smith</td><td style="text-align: right;;">20</td><td style="text-align: right;;"></td><td style=";">Apples</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">3</td><td style=";">Apples</td><td style=";">Cooking</td><td style="text-align: right;;">10</td><td style="text-align: right;;"></td><td style=";">Cooking</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">4</td><td style=";">Apples</td><td style=";">Bramley</td><td style="text-align: right;;">15</td><td style="text-align: right;;"></td><td style="text-align: right;;">10</td></tr></tbody></table><p style="width:4em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid rgb(187,187,187);border-top:none;text-align: center;background-color: rgb(218,231,245);color: rgb(22,17,32)">Names</p><br /><br /><table width="85%" cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: rgb(255,255,255)" ><tr><td style="padding:6px" ><b>Array Formulas</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: rgb(255,255,255);border-collapse: collapse; border-color: rgb(187,187,187)"><thead><tr style=" background-color: rgb(218,231,245);color: rgb(22,17,32)"><th width="10px">Cell</th><th style="text-align:left;padding-left:5px;">Formula</th></tr></thead><tbody><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">E4</th><td style="text-align:left">{=INDEX(<font color="Blue">C2:C4,MATCH(<font color="Red">E2&"|"&E3,A2:A4&"|"&B2:B4,0</font>)</font>)}</td></tr></tbody></table><b>Entered with Ctrl+Shift+Enter.</b> If entered correctly, Excel will surround with curly braces {}.
<b>Note: Do not try and enter the {} manually yourself</b></td></tr></table><br />
 

Forum statistics

Threads
1,085,334
Messages
5,383,024
Members
401,812
Latest member
topherj09

Some videos you may like

This Week's Hot Topics

Top