Solved

Way to find first date that occurs after another date in a column

Posted on 2011-02-22
8
265 Views
Last Modified: 2012-05-11
I have a column with dates in it.  I'd like to find the earliest date that occurs after 12/31/08.  In other words, if I have:
1/4/08
2/23/08
4/3/08
12/30/08
4/1/09
5/8/09
11/25/09
1/1/10
5/6/10
12/4/10
1/23/11

I'd like it to return: 4/1/09
0
Comment
Question by:BBlu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
8 Comments
 
LVL 22

Expert Comment

by:rspahitz
ID: 34956516
If you can sort the dates, the the VLOOKUP is perfect for this:

if B1 =12/31/08
B2 =VLOOKUP(B1, $A$1:$A$100, 1)
0
 
LVL 50

Accepted Solution

by:
barry houdini earned 75 total points
ID: 34956572
Hello rspahitz,

That will return the largest date on or before 12/31/08, in this case that's 12/30/08

BBlu

Assuming the dates are in ascending order like your example then you can use this formula

=INDEX(A2:A12,MATCH(C2+1,A2:A12)+(LOOKUP(C2+1,A2:A12)<>C2+1))

or an "array formula" to do the same which works with the dates in any order

=MIN(IF(A2:A12>C2,A2:A12))

format result cell as date

where A2:A12 contains your dates and C2 the date to match (12/31/08 in your example)

regards, barry
0
 
LVL 33

Assisted Solution

by:jppinto
jppinto earned 75 total points
ID: 34956592
If your values are on column A, put the 12/31/08 value on cell C2 and on cell C1 put this formula:

=MIN(IF(A1:A10>C2;A1:A10))

After you entered the formula in the formula bar you have to make it an array formlua by pressing CTRL+SHIFT+ENTER. Your formula should look like this:

{=MIN(IF(A1:A10>C2;A1:A10))}

jppinto
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 50

Expert Comment

by:barry houdini
ID: 34956599
See attached for examples of both formulas I suggested

regards, barry
26840320.xls
0
 
LVL 33

Expert Comment

by:jppinto
ID: 34956602
Attched working example...
MinDate.xlsx
0
 
LVL 22

Assisted Solution

by:rspahitz
rspahitz earned 75 total points
ID: 34956656
Barry, you're right (you knew that!) that the date returned with mine will be the highest date that does not EXCEED the specified date.

This will work, if you insert a new column B with a simple sequence of 1 for the first date, 2 for the next date, etc (again, assuming the dates are sorted):

=INDIRECT("A"&VLOOKUP(C1,$A$1:$B$100,2)+1)

1/4/2008	1	12/31/2008
2/23/2008	2	4/1/2009 (formula in message)
4/3/2008	3	
12/30/2008	4	
4/1/2009	5	
5/8/2009	6	
11/25/2009	7	
1/1/2010	8	
5/6/2010	9	
12/4/2010	10	
1/23/2011	11

Open in new window

0
 

Author Comment

by:BBlu
ID: 34956759
Thank you all.  I was working along the lines of the min() function with an array formula, but failed to think of the if statement part.  I also like the vlookup suggestion because it allows for finding the nth date.  Thank you all.  As usual, you guys are amazing.
0
 

Author Closing Comment

by:BBlu
ID: 34956767
Thank you all!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Macro to Lock and Unlock a Worksheet ONLY 12 35
any combination of this numbers 9 33
Help to find the duplicates 8 21
Excel VBA Sort Toggle 5 14
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question