Help with arrays and if statements

mkramer1

New Member
Joined
Jun 8, 2016
Messages
3
I have three columns of dates. Each row corresponds to one item. I want to find the closest future date to today. So I used this
=MIN(IF(G23:I23>$E$1,G23:I23)). However, for two items, the dates are all less than TODAY(). For that I would like to find the furthest past date from TODAY() that is not 01-01-00. I would like a formula that I could drag down for all items, despite having future of past dates. I need this because my dates correspond to data from a web query, so the dates may change from past to future depending on the dates on the website. I tried using the formula below (I know I used MAX because I didn't know how to exclude 01-01-00), but it gives a #VALUE error sometimes, and sometimes it doesn't.

IF(MIN(IF(G27:I27>$E$1,G27:I27))=TRUE,MIN(IF(G27:I27>$E$1,G27:I27)),(DATE(YEAR(MAX(IF(G27:I27<$E$1,G27:I27)))+2,MONTH(MAX(IF(G27:I27<$E$1,G27:I27)))+6,DAY(MAX(IF(G27:I27<$E$1,G27:I27))))))

If anyone could help me figure this out, I would greatly appreciate it. I have tried reading about arrays but it hasn't gotten me anywhere :(.

The first picture shows the values when the first formula is used for all rows. The second picture shows the value error when only that row uses the latter formula.

eAxn8BI.png
[/URL][/IMG]
Jyqq9nr.png
[/URL][/IMG]
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
19-06-1819-06-1619-06-20
26-09-1726-09-1726-09-19
01-03-2101-12-1931-03-18
01-03-2101-12-1931-03-18
01-03-1601-03-1600-01-00
24-11-1924-11-1725-11-16
21-10-1921-10-1722-10-16
01-03-1601-03-1600-01-00
14-05-1814-05-1814-05-20
07-05-1807-05-1807-05-20

<tbody>
</tbody>
the actual data, sorry I forgot to include it in the post.
 
Upvote 0
I'm not quite sure what you mean by "furthest past date from TODAY()" so I've given two options:


Book1
GHIJK
2319-06-1819-06-1619-06-2019-06-1619-06-16
2426-09-1726-09-1726-09-1926-09-1726-09-17
2501-03-2101-12-1931-03-1831-03-1831-03-18
2601-03-2101-12-1931-03-1831-03-1831-03-18
2701-03-1601-03-1600-01-0001-03-1601-03-16
2824-11-1924-11-1725-11-1625-11-1625-11-16
2921-10-1921-10-1722-10-1622-10-1622-10-16
3001-03-1601-03-1600-01-0001-03-1601-03-16
3114-05-1814-05-1814-05-2014-05-1814-05-18
3207-05-1807-05-1807-05-2007-05-1807-05-18
Sheet1
Cell Formulas
RangeFormula
J23{=IF(MIN(IF(G23:I23>$E$1,G23:I23)) = 0, MIN(IF(G23:I23=0,99999,G23:I23)), MIN(IF(G23:I23>$E$1,G23:I23)))}
K23{=IF(MIN(IF(G23:I23>$E$1,G23:I23)) = 0, MAX(G23:I23), MIN(IF(H23:J23>$E$1,G23:I23)))}
Press CTRL+SHIFT+ENTER to enter array formulas.


Column J should pick the earliest date that isn't 00-01-00. Column K should pick the nearest date to TODAY(). BTW, I have $E$1 = TODAY().

WBD
 
Upvote 0
Thank you so much, this was extremely helpful!

By furthest past date, I meant that between the three dates, 01-01-15,01-01-16,01-01-00, it would return 01-01-15 since it is the furthest date, in the past, from TODAY() that isn't 01-01-00.
 
Upvote 0
a
b
c
d
e
1
1/1/2015​
1/1/2016​
1/1/2000​
1/1/2015​

<tbody>
</tbody>

e1=MIN(IF(A1:C1<TODAY(),IF(A1:C1<>C1,A1:C1))) control+shift+enter
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,523
Messages
6,125,323
Members
449,218
Latest member
Excel Master

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