Nearest Less than date after vlookup

beamo

New Member
Joined
Jul 13, 2011
Messages
3
Hi All,

Heaven knows if I'm explaining my problem correctly but here goes.

I have some customers who can make two different types of transactions which are inter-related. Each transaction can be made many times.

So worksheet 1 lists transaction one with a customer number, effective date and payment amount.

worksheet 2 lists transaction two with a customer number, effective date and transaction data.

I want to append the relevant information from worksheet 2 to worksheet 1. The rules arethe customer number must match and the effective date I want to grab from worksheet 2 is the entry that is nearest to, but less than the effective date I am looking at in worksheet 1. Once I get that date in, it should be easy to vlookup the other details with an IF AND function.

Here's hoping I made some sense ?
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Welcome to the board

If the data in worksheet 2 can be sorted ASCENDING by the effective date
Then you can use vlookup on the effective date column using TRUE as the 4th argument in the vlookup.

Hope that helps.
 
Upvote 0
The problem I have is there could be multiple entries in the transaction 2 worksheet that are for dates both before and after the relevant date in worksheet 1 that I am trying to get closest to.

I don't think the Vlookup will pick the nearest date relevant for the matching customer number. It will pick the first or the last depending on order, but I need it to look at each date and pick the closest.
 
Upvote 0
It works for me...

Provided the Data in Sheet 1 is sorted ASCENDING by the dates..
When using TRUE as 4th argument in Vlookup, it will find the closest value that is less than or equal to the lookup value.


Excel Workbook
AB
1Date to findResult
26/11/2011c
36/24/2011e
46/7/2011a
57/1/2011e
67/9/2011h
Sheet2
Excel Workbook
AB
1DateValue
26/1/2011a
36/10/2011b
46/11/2011c
56/19/2011d
66/24/2011e
77/4/2011f
87/8/2011g
97/9/2011h
107/14/2011i
Sheet1
 
Upvote 0
Ok, looks good, but how do I incorporate the match on customer number as well.

Both sheets will hold multiple customers and I only want the vlookup to refer to the dates that are relevant for the customer number being checked ?
 
Upvote 0

Forum statistics

Threads
1,224,578
Messages
6,179,654
Members
452,934
Latest member
mm1t1

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