VLOOKUP with 2 criterias

LaurenHancy

Board Regular
Joined
Aug 5, 2010
Messages
179
Hi All,

I am having a real problem with return the time of a cell using 2 criterias:

This is the data table:

A B C D

1 02/01/19 John 08:16 06:40
2 03/01/19 Bob 08:20 05:30
3 04/05/19 John 09:45 06:44
4 04/03/19 David 08:20 07:55

I am wanting to do an index search as per the following into each date collumn I have. As the referance collumns are not underneath each other, my VLOOKup doesnt work, it just returns #N/A.

=VLOOKUP(A6&D5, RAW_UserAvSum_DATA, 3,FALSE)

A6 = Name
D5 = Date

I want to return Collumn C, first time record.

Thank you for helping me x
 
Re: Please help me, I'm stuck :) - VLOOKUP with 2 criterias

That means the result is false so those two cells are not equal even if they appear to be. Is the sumproduct returning #N/A?
 
Upvote 0

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Re: Please help me, I'm stuck :) - VLOOKUP with 2 criterias

results from post #2 & #3's formula

ABC
D
John
Bob
John
David
John

<colgroup><col style="width: 25pxpx"><col><col><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]
[TD="align: right"]02/05/2019[/TD]

[TD="align: right"]08:16[/TD]
[TD="align: right"]06:40[/TD]

[TD="align: center"]2[/TD]
[TD="align: right"]03/01/2019[/TD]

[TD="align: right"]08:20[/TD]
[TD="align: right"]05:30[/TD]

[TD="align: center"]3[/TD]
[TD="align: right"]04/05/2019[/TD]

[TD="align: right"]09:45[/TD]
[TD="align: right"]06:44[/TD]

[TD="align: center"]4[/TD]
[TD="align: right"]04/03/2019[/TD]

[TD="align: right"]08:20[/TD]
[TD="align: right"]07:55[/TD]

[TD="align: center"]5[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"]04/05/2019[/TD]

[TD="align: center"]6[/TD]

[TD="align: right"][/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=E2EFDA]#E2EFDA[/URL] , align: right"]09:45[/TD]
[TD="align: right"][/TD]

[TD="align: center"]7[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]8[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=E2EFDA]#E2EFDA[/URL] , align: right"]09:45[/TD]
[TD="align: right"][/TD]

</tbody>
Sheet9

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Worksheet Formulas[TABLE="width: 100%"]
<thead>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]
[TH="width: 10px"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
</thead><tbody>[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]C6[/TH]
[TD="align: left"]=SUMPRODUCT(--($A$1:$A$4=D5),--($B$1:$B$4=A6),$C$1:$C$4)[/TD]
[/TR]
[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]C8[/TH]
[TD="align: left"]=INDEX(C1:C4,MATCH(1,INDEX((A1:A4=D5)*(B1:B4=A6),0),0))[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]

I can get this to work on a blank spreadsheet but it isnt working on my main spreadsheet, would it be because the data I am using is imported using =TEXT(**,"DD/MM/YYY")?
 
Upvote 0
Re: Please help me, I'm stuck :) - VLOOKUP with 2 criterias

instead of import using =TEXT(**,"DD/MM/YYY"), try =TEXT(**,"DD/MM/YYY")+0
 
Upvote 0
Re: Please help me, I'm stuck :) - VLOOKUP with 2 criterias

It has worked! Thank you very much :)

=TEXT(**,"DD/MM/YYY")+0
 
Upvote 0
Re: Please help me, I'm stuck :) - VLOOKUP with 2 criterias

this is the modified version


Book1
ABCD
102/05/2019John08:1606:40
203/01/2019Bob08:2005:30
304/05/2019John09:4506:44
404/03/2019David08:2007:55
504/05/2019
6John09:45
7
809:45
Sheet9
Cell Formulas
RangeFormula
C6=SUMPRODUCT(--(TEXT($A$1:$A$4,"dd/mm/yyyy")+0=D5),--($B$1:$B$4=A6),$C$1:$C$4)
C8=INDEX(C1:C4,MATCH(1,INDEX((TEXT(A1:A4,"dd/mm/yyyy")+0=D5)*(B1:B4=A6),0),0))
 
Upvote 0
Re: Please help me, I'm stuck :) - VLOOKUP with 2 criterias

Based on your opening post:

I want to return Collumn C, first time record.

do not use the SUMPRODUCT. It will add the times together if multiple entries exist.
 
Upvote 0
Re: Please help me, I'm stuck :) - VLOOKUP with 2 criterias

It has worked! Thank you very much :)

=TEXT(**,"DD/MM/YYY")+0

you're welcome.
as Steve suggest the index/match option is more robust
 
Upvote 0
Re: Please help me, I'm stuck :) - VLOOKUP with 2 criterias

Hi Lauren,

It looks like you have your A6 and D5 the wrong way around. D5 should be in the first part of the formula I think.

Owain
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,325
Members
452,635
Latest member
laura12345

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