Lookup date with largest value between 2 dates

wallstudio

New Member
Joined
Oct 19, 2010
Messages
36
I have worksheet with 2 columns. Column A are date in ascending order. Column B are numbers. C1 and C2 are dates for me to input. C3 is the result.

I need to find the largest number in column B which is between dates of C1 and C2 and return the corresponding date as result.

Have been thinking for a while and can't figure it out. Can anyone help? Thanks a lot.
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
This works, though I'm sure there's a better and less complicated way to do it.

It doesn't account for duplication of the largest number, so maybe you need to figure that out if that's a possibility.

I've gone down to row 24 in the formula, but change that to suit your range

=INDEX(A1:A24,MATCH(MAX(OFFSET(A1,MATCH(C1,A1:A24,0)-1,1,(C2-C1)+1,1)),B1:B24,0),1)
 
Last edited:
Upvote 0
I think the (C2-C1)+1 portion of the formula is miscalculating;
The largest Number between the dates in C1 and C2 is on row 12 - dated 1/18/2011..
Excel Workbook
ABCD
11/16/2011501/17/2011<< Between
21/16/20111001/18/2011<< Between
31/16/20115001/17/2011<< The related Date of the Largest Number between C1 and C2
41/16/201125
51/17/201130
61/17/2011325
71/17/2011250
81/17/201150
91/17/2011150
101/18/201131
111/18/2011444
121/18/2011951<<???????????
131/18/201124
141/19/20113524
151/19/201121
161/19/201154
171/19/20119541
Sheet1
Excel 2007
Cell Formulas
RangeFormula
C3=INDEX(A:A,MATCH(MAX(OFFSET(A1,MATCH(C1,A:A,0)-1,1,(C2-C1)+1,1)),B:B,0),1)
 
Upvote 0
I think the (C2-C1)+1 portion of the formula is miscalculating;

That bit is just to ensure the dates are inclusive. 17/01 - 16/01 is 1, so the +1 is making sure that both days are counted.

It didn't miscalculate for me.
 
Upvote 0
I think the (C2-C1)+1 portion of the formula is miscalculating;
The largest Number between the dates in C1 and C2 is on row 12 - dated 1/18/2011..
Excel Workbook
ABCD
11/16/2011501/17/2011<< Between
21/16/20111001/18/2011<< Between
31/16/20115001/17/2011<< The related Date of the Largest Number between C1 and C2
41/16/201125
51/17/201130
61/17/2011325
71/17/2011250
81/17/201150
91/17/2011150
101/18/201131
111/18/2011444
121/18/2011951<<???????????
131/18/201124
141/19/20113524
151/19/201121
161/19/201154
171/19/20119541
Sheet1
Excel 2007
Cell Formulas
RangeFormula
C3=INDEX(A:A,MATCH(MAX(OFFSET(A1,MATCH(C1,A:A,0)-1,1,(C2-C1)+1,1)),B:B,0),1)

Just looking at your example, there. My formula obviously doesn't like it when dates are repeated. It works fine when there's just one entry per day, though, which is what I assumed would be the case.
 
Upvote 0
I haven't come up with a sensible formula myself yet but I don't think either of the 2 suggestions so far work. Note that my dates are d/mm/yyyy


Excel Workbook
ABCD
14/04/2011
21/04/201159/04/2011
32/04/2011692/04/2011Not between C1 and C2 dates
43/04/20114
54/04/20118
65/04/20115
76/04/201169
87/04/20113
98/04/20112
109/04/20115
1110/04/20118
1211/04/20116
1312/04/20113
14
Largest between 2 dates Expiry




Excel Workbook
ABCD
14/04/2011
21/04/201159/04/2011
32/04/2011692/04/2011Not between C1 and C2 dates
43/04/20114
54/04/20118
65/04/20115
76/04/201169
87/04/20113
98/04/20112
109/04/20115
1110/04/20118
1211/04/20116
1312/04/20113
14
Largest between 2 dates jim may
 
Upvote 0
Peter, Mine was not a Suggestion -- I was questioning the original suggestion;
Note that I considered multiple dates - not sure if OP has multiple dates or not..
Jim
 
Upvote 0
Peter, I recognised that situation wasn't covered in my formula. Hopefully someone will be able to tweak it.

This problem sounds like it should be really simple.
 
Upvote 0
First of all, thanks for all yours ideas. And Sorry guys! I didn't make it very clear at first. Dates are not repeated in column A.

Also, don't know if there is any difference for the formula if there is a header on the top row, cos I see offset function in the formula.
 
Upvote 0
See if this is it. These are array formulas so should be entered without the {} but confirmed with Ctrl+Shift+Enter, not just Enter. If confirmed correctly, Excel will insert the {}.

Excel Workbook
ABCD
14/04/201169
21/04/201159/04/2011
32/04/2011696/04/2011
43/04/20114
54/04/20118
65/04/20115
76/04/201169
87/04/20113
98/04/20112
109/04/20115
1110/04/20118
1211/04/20116
1312/04/20113
14
Largest between 2 dates




This still doesn't cover the circumstance that the largest number in the date range occurs more than once in the date range as shown below.
1. Is that possible?
2. What result(s) would you want in that circumstance?

Excel Workbook
ABC
14/04/2011
21/04/201159/04/2011
32/04/201169
43/04/20114
54/04/20118
65/04/201169
76/04/201169
87/04/20113
98/04/201169
109/04/20115
1110/04/20118
1211/04/20116
1312/04/20113
14
Largest between 2 dates (2)
 
Upvote 0

Forum statistics

Threads
1,224,574
Messages
6,179,628
Members
452,933
Latest member
patv

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