VLOOKUP in a dynamic range

war4peace

New Member
Joined
Mar 13, 2009
Messages
21
Hi everyone,

I have been struggiling with this for a couple days now and I am *this* close but then the solution eludes me.
I have two spreadsheets with two columns each (there are more columns but only two are used at the moment):

Spreadsheet 1 (sample):

e-mail address
timestamp
john.doe@website.com
01.08.2014 03:10:07
jane.doe@website.com
01.08.2014 03:10:10

<colgroup><col width="203"></colgroup><tbody>
</tbody>
someone.else@website.com
01.08.2014 03:10:14

<colgroup><col width="203"></colgroup><tbody>
</tbody>
another.user@website.com
01.08.2014 03:10:21

<colgroup><col width="203"></colgroup><tbody>
</tbody>

<tbody>
</tbody>

Spreadsheet 2 (sample):


e-mail address
timestamp
john.doe@website.com
01.08.2014 03:14:10

<colgroup><col width="203"></colgroup><tbody>
</tbody>
jane.doe@website.com
01.08.2014 03:18:14

<colgroup><col width="203"></colgroup><tbody>
</tbody>
luke.skywalker@website.com
01.08.2014 03:21:21

<colgroup><col width="203"></colgroup><tbody>
</tbody>
john.doe@website.com
01.08.2014 06:44:11

<tbody>
</tbody>

What I need to do is take the first e-mail address from Spreadsheet 1 and verify whether they exist in Spreadsheet 2 but only in a range bounded by the corresponding timestamp in Spreadsheet 1 (lower bound) and the same timestamp + 1h (upper bound).

Example:

John Doe has a timestamp of "01.08.2014 03:10:07" in Spreadsheet 1 and two timestamps in spreadsheet 2. When I look up his e-mail address in spreadsheet 2, I would see two values but the second one doesn't match my lookup constraints, therefore I need to only lookup in the range expanding at most 1h after their Spreadsheet 1 timestamp.

What I tried:

- Match() to obtain the lower bound of the lookup array, and that works:
Code:
=MATCH(1;('S1'!$D$2:$D$3493>='S2'!D2)*('S1'!$D$2:$D$3493<'S2'!F2);0)
But I can't obtain the upper bound.

- INDEX combined with MATCH to get the actual value in, but for some reason I end up with a humongous formula which doesn't do much.

The output should be 0 if the e-mail address is not in the range and 1 if it is.

I can create a VBA script which would to what I need but then I'll have to share that file with other people (read: management) and they don't like macros. Sadly, I'm fairly bad at matching formulas together.

Thanks in advance for responding to my question!
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Quick update, I wrote a small VBA script which does the job, but still looking for a formula-based approach.
 
Upvote 0

Forum statistics

Threads
1,215,467
Messages
6,124,984
Members
449,201
Latest member
Lunzwe73

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