VBA Question - Sorting using two sets of criteria and finding the closest 4 numbers....

Eslava

Board Regular
Joined
Nov 20, 2007
Messages
112
I have two sets of data:

Data set #1

Indicator Price Indicator Price Date
2.1 10/27/08
2.11 10/22/08
2.17 11/21/08
2.38 03/20/09
2.38 03/25/09
2.46 03/19/09
2.5 03/09/09
2.5 03/24/09
2.53 12/04/08
2.73 12/09/08
2.82 12/24/08
2.83 12/18/08
2.89 12/12/08
2.9 03/13/09

Data set #2:

Close Price Close Price Date s1 s2 s3 s4 r1 r2 r3 r4
2.25 12/11/09
2.30 12/12/09
2.40 12/13/09
2.00 12/14/09
2.12 12/15/09
2.50 12/16/09
2.51 12/17/09
2.53 12/18/09
2.49 12/19/09

What I'm attempting to do is find what are the CLOSEST four indicator prices in data set #1 are above (r1, r2, r3, r4) and below (s1, s2, s3, s4) the closing price in data set #2. Also, I can only use the indicator numbers in data set #1 that are on or before the close price date in data set #2. Because of this, not all of the r's and s's will be filled in.

I would like to use just regular excel formulas, but I have a feeling that VBA may be my only option.

Any help would be greatly appreciated. Let me know if you have any other questions.

Cheers!
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Data Set #1

Excel 2010
AB
1Indicator PriceIndicator Price Date
22.110/27/2008
32.1110/22/2008
42.1711/21/2008
52.383/20/2009
62.383/25/2009
72.463/19/2009
82.53/9/2009
92.53/24/2009
102.5312/4/2008
112.7312/9/2008
122.8212/24/2008
132.8312/18/2008
142.8912/12/2008
152.93/13/2009
Sheet1


Data Set #2

Excel 2010
HIJKLMNOPQ
1Close Price DateClose Prices1s2s3s4r1r2r3r4
22.2512/11/2009
32.312/12/2009
42.412/13/2009
5212/14/2009
62.1212/15/2009
72.512/16/2009
82.5112/17/2009
92.5312/18/2009
102.4912/19/2009
Sheet1
 
Upvote 0

Forum statistics

Threads
1,214,923
Messages
6,122,286
Members
449,076
Latest member
kenyanscott

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