Last date before a certain date

m.cuccovillo

New Member
Joined
Feb 6, 2010
Messages
5
Dear all,
I have been trying a solution to this jigsaw for ages... would save me years of boring work!

Basically I need a cell to return the latest date in a the first column before a certain date, if in the following column there is a "1".

Example:

A1... B..............C...............D
2..................... site1..........site2
3......last...........07-Feb.......03-Feb
4...... next.........13-Feb.......10-Feb
5...... update......09-Feb.......09-Feb
6...... 01-Feb
7...... 02-Feb.......................1
8...... 03-Feb.......................1
9...... 04-Feb
10.....05-Feb.......1
11.....06-Feb
12.....07-Feb.......1
13.....08-Feb
14.....09-Feb
15.....10-Feb.......................1
16.....11-Feb
17.....12-Feb
18.....13-Feb.......1
19.....14-Feb.......1

Basically I would like cell D3 to display the last date where there is a 1 in column D BEFORE the last update, wrote manually in cell D5.
Similar thing for cell D4, which should return the first date where there is a 1 in column D AFTER the last update.

Can anyone help me at all?

Thank you very much!

Michele
 
Last edited:

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
There are a few ways you could approach this - MIN & MAX Arrays etc etc, below is just one:


Excel Workbook
BCD
3last07-Feb03-Feb
4next13-Feb10-Feb
5update09-Feb09-Feb
601-Feb
702-Feb1
803-Feb1
904-Feb
1005-Feb1
1106-Feb
1207-Feb1
1308-Feb
1409-Feb
1510-Feb1
1611-Feb
1712-Feb
1813-Feb1
1914-Feb1
Sheet1


note: with the above approaches you would still want/need to account for possibility of no match.
 
Upvote 0
Thank you so much for your help! I wasn't even that hopeful that a solution might have existed.

Untitled.jpg


To be more accurate and using my actual spreadsheet, for the cell H18 I have used the formula:
=LOOKUP(9.99E+307,H$21:INDEX(H$21:H$280,MATCH(H$20,$D21:$D280)-1),$D$21:INDEX($D21:$D280,MATCH(H$20,$D21:$D280)-1))

For the cell H19 (which should return the first date after the update date that is in H20), the formula you suggested does not work. But I also have realised that it is because I have originally posted too little information...
Do you reckon is there any formula I can use with my spreadsheet?

Thank you again!

P.S.: The formula should just traces "1s" and not any other sign like "Cs" or whaterver... your H18 cell does it already!
 
Upvote 0
The formula for F19 (adapted from C4 in earlier ex.) should read:

Code:
=INDEX(INDEX($D:$D,MATCH(F$20,$D:$D)+1):$D$280,MATCH(1,INDEX(F:F,MATCH(F$20,$D:$D)+1):F$280,0))
copied across

Using the above formula with your (visible) values the above would return the below:

Excel Workbook
DEFGHI
19#N/A11-Feb24-Feb17-Feb
2010-Feb10-Feb10-Feb10-Feb
2103-Jan
2204-JanC
2305-JanC
2406-JanC
2507-JanC
4131-Jan
4201-Feb1
4302-Feb1
4403-Feb
4504-Feb
4607-Feb1
4708-Feb1
4809-Feb
4910-Feb1
5011-Feb1
5114-Feb
5215-Feb
5316-Feb
5417-Feb1
5518-Feb1
5621-Feb
5722-Feb1
5823-Feb
5924-Feb1
6025-Feb1
Sheet1


Note:

-- the error in F is expected give no 1 appears post 10-Feb in the values I can see.
-- rows 26:40 are grouped/hidden per your screenshot
 
Upvote 0

Forum statistics

Threads
1,223,249
Messages
6,171,031
Members
452,374
Latest member
keccles

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