Hi all,
Any idea how I can select the closest date to a 30 days ago ? Vlookup & Co only deliver the largest date that is smaller then the selection, not necessarily the closest. Here is an example:
Col A Col B Col C
"DATE" "DATA" "Last 30 day Average of Data"
25/10/2009 5 "formula to calculate the average of the last 30 days"<formula to="" calculate="" average="" of="" last="" 30="" days="" until="" date="">
26/11/2012 6 <formula to="" calculate="" average="" of="" last="" 30="" days="" until="" date="">"formula to calculate the average of the last 30 days"
25/12/2012 7 <formula to="" calculate="" average="" of="" last="" 30="" days="" until="" date="">"formula to calculate the average of the last 30 days"
Match and Vlookup in C5 will look at the 2009 date but of course 26/11/2012 is much closer to -30 days than the 2009 date.
I have written a macro to solve this - but I'd like a formula in Col C. It should not be an array formula as this formula has to work on about 300 rows in Col C.
I found this - which is an array, hence not tested:
=INDEX(Datelist, MATCH(MIN(ABS(Datelist-A1)), ABS(Datelist-A1), 0))
The date list is sorted by date.
Any help would be very much appreciated.</formula></formula></formula>
Any idea how I can select the closest date to a 30 days ago ? Vlookup & Co only deliver the largest date that is smaller then the selection, not necessarily the closest. Here is an example:
Col A Col B Col C
"DATE" "DATA" "Last 30 day Average of Data"
25/10/2009 5 "formula to calculate the average of the last 30 days"<formula to="" calculate="" average="" of="" last="" 30="" days="" until="" date="">
26/11/2012 6 <formula to="" calculate="" average="" of="" last="" 30="" days="" until="" date="">"formula to calculate the average of the last 30 days"
25/12/2012 7 <formula to="" calculate="" average="" of="" last="" 30="" days="" until="" date="">"formula to calculate the average of the last 30 days"
Match and Vlookup in C5 will look at the 2009 date but of course 26/11/2012 is much closer to -30 days than the 2009 date.
I have written a macro to solve this - but I'd like a formula in Col C. It should not be an array formula as this formula has to work on about 300 rows in Col C.
I found this - which is an array, hence not tested:
=INDEX(Datelist, MATCH(MIN(ABS(Datelist-A1)), ABS(Datelist-A1), 0))
The date list is sorted by date.
Any help would be very much appreciated.</formula></formula></formula>
Last edited: