
Originally Posted by
Rick Rothstein
It does not actually display the "correct data", rather, it display the first row number of a date in B7:B2500 that is greater than or equal to the date in A4, if there is one. Here is a shorter bit of code (actually, a one-liner) that should do the same thing...
Code:
Sub DateTooLate()
MsgBox Replace(Evaluate("MIN(IF(B7:B2500>=A4,ROW(B7:B2500),99999))"), 99999, "All OK")
End Sub
snb's post reminded me that I used more code than was needed in the above macro as this shorter code would work the same (although it does not report "All OK" if all the dates are less than A4's date; rather, it does nothing which matches what PcMax's code does in that circumstance)...
Code:
Sub DateTooLate()
MsgBox Evaluate("MIN(IF(B7:B2500>=A4,ROW(B7:B2500),""""))")
End Sub
And while I hate the square bracket notation snb used in his post, the above would be shortened even more by using it (assuming you do not mind that notation)...
Code:
Sub DateTooLate()
MsgBox [MIN(IF(B7:B2500>=A4,ROW(B7:B2500),""))]
End Sub
Bookmarks