Compare Dates --From List of Dates Sorted Descending, Determine "Last" Date Greater Than Comparison Date -- Excel 2010

supertemp123

New Member
Joined
Jan 17, 2013
Messages
3
Hi,

In Excel 2010, I am trying to create a calculator to do the following:

Compare one date ("control date") to a list of dates ("list dates") and determine which date from that list is the first one to occur after the date in question (i.e. the last "greater than" date when looking at a descending list of dates).

The "list dates" are generally one date a year, but not always.

I have tried:


  1. Subtracting the "list dates" from the "control dates" and copying that formula down until I hit a negative number.
    • This brings up the negative dates problem, however, and I can't change my workbook to the 1904 dates, since the actual dates will be recorded on a worksheet that will later be printed (a "written record" of the calculation). For these last cell formulas, can it just look for the last "valid" cell (i.e. not #NUM!)?
  2. Using an IF statement to designate those dates that are GREATER THAN the "control date" (and setting TRUE to "1" and FALSE to "0") and noting where these become 0/False.
    • I see the last cell before it becomes "0", but how do I record it in another cell?

I am not having luck with ".End(xlup)" -- is this how I should approach this -- I don't want last cell with any value, but last cell with a particular value (i.e. greater than 0/Positive/True)? I am not a VB expert, but could, in a pinch, perhaps get it to work.
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Welcome to the board.

Here's how you can do it with a Formula

=INDEX(F1:F10,MATCH(A1,F1:F10,-1))

A1 = Control Date
F1:F10 = List Dates (sorted DEscending)

Hope that helps.
 
Upvote 0
If your dates are sorted in descending order:
Excel Workbook
ABC
1DatesCtrl DateFirstAfter
26/25/20142/7/20133/2/2013
35/26/2014
44/26/2014
53/27/2014
62/25/2014
71/26/2014
812/27/2013
911/27/2013
1010/28/2013
119/28/2013
128/29/2013
137/30/2013
146/30/2013
155/31/2013
165/1/2013
174/1/2013
183/2/2013
191/31/2013
201/1/2013
Sheet5
 
Upvote 0
Thank you very much. This worked great -- much simpler than the convoluted logic I used (described later).

Do you know how I would do the opposite? Meaning take another control date (this one later than the first one), matching it against the same list (sorted descending), and finding the first date BEFORE the date in question? In other words, or this second number, the period does NOT count the index date that is outside the date range (the range between control date #1 and control date #2) -- the last "list date" counted in the period is the last date BEFORE control date # 2.

The way I attacked the problem was to run the same formula against the list for both dates and find the "union" where date #1 is greater and date #2 is not greater.

=ADDRESS(MAX(IF(NumRange=MAX(NumRange),ROW(NumRange))),COLUMN(NumRange),4)

I did an "IF TRUE" test for this date greater than the other for control #1 and control #2, indicated where the LIST DATE was greater than the control date for both control numbers. From that, I did a concatenate and figured out the UNION of dates where the control date #1 was greater than the list date AND the dates where the control date #2 was less than the list date. The "TRUEFALSE" subset of dates.

LIST DATES: CONTROL DATE #1 -- 10/15/94 (ED -- Early Date) -- List Date is Greater? CONTROL DATE #2 -- 5/17/06 (LD -- Later Date) -- List Date is Greater?
12/1/2012 TRUE TRUE
12/1/2011 TRUE TRUE
12/1/2010 TRUE TRUE
12/1/2009 TRUE TRUE
12/1/2008 TRUE TRUE
12/1/2007 TRUE TRUE
12/1/2006 TRUE TRUE
12/1/2005 TRUE FALSE
12/1/2004 TRUE FALSE
12/1/2003 TRUE FALSE
12/1/2002 TRUE FALSE
12/1/2001 TRUE FALSE
12/1/2000 TRUE FALSE
12/1/1999 TRUE FALSE
12/1/1998 TRUE FALSE
12/1/1997 TRUE FALSE
12/1/1996 TRUE FALSE
12/1/1995 TRUE FALSE
12/1/1994 TRUE FALSE
12/1/1993 FALSE FALSE
12/1/1992 FALSE FALSE

From this "subset" of the greater list, however, I need to somehow indicate on a separate spreadsheet whichever dates are in this subset .. e.g. A1 is date #1 (here 12/1/95), A2 is date #2 (here 12/1/96) -- ascending or descending doesn't matter -- just need to generate this "report". How do I tell the spreadsheet to "copy" this result to another sheet? Is this a Macro? VBA? I need the report to obviously allow enough space for however many dates there are in the period being examined.

The other column of the report would be the column with the rates -- would this just be a VLOOKUP against the table with dates and rates?

e.g.

12/1/95 8%
12/1/96 9%
12/1/97 4%

I apologize for asking ... I am not the normal person at work who has to do these things. I hope to contribute myself once I have more to offer the community.

Thanks again for all of your help (and JonMo's help).
 
Upvote 0

Forum statistics

Threads
1,226,523
Messages
6,191,551
Members
453,662
Latest member
Xcelling

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