Results 1 to 10 of 10

Thread: Find... >= tDate

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Forum Guru Rick Rothstein's Avatar
    Join Date
    Feb 2012
    Posts
    662
    Rep Power
    15
    Quote Originally Posted by Rick Rothstein View Post
    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
    Last edited by Rick Rothstein; 01-28-2013 at 08:34 PM.

  2. #2
    Senior Member
    Join Date
    Oct 2011
    Posts
    135
    Rep Power
    15
    Quote Originally Posted by Rick Rothstein View Post
    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
    I have tested all your code, thank you for your suggestions.
    The code I must return a single value as indicated by Rick at the beginning of the range of my research.
    To complete my selection I just have to find a different formula with the value: B7:B2500<=B4 (B4 value > A4)

  3. #3
    Forum Guru Rick Rothstein's Avatar
    Join Date
    Feb 2012
    Posts
    662
    Rep Power
    15
    Are you looking for something like this?
    Code:
    Sub DateJustRight()
      MsgBox Evaluate("MAX(IF((B7:B2500>=A4)*(B7:B2500<=B4),ROW(B7:B2500),))")
    End Sub

  4. #4
    Senior Member
    Join Date
    Oct 2011
    Posts
    135
    Rep Power
    15
    Quote Originally Posted by Rick Rothstein View Post
    Are you looking for something like this?
    Code:
    Sub DateJustRight()
      MsgBox Evaluate("MAX(IF((B7:B2500>=A4)*(B7:B2500<=B4),ROW(B7:B2500),))")
    End Sub
    Thank you very much for the control of dates

Similar Threads

  1. Replies: 4
    Last Post: 04-05-2013, 12:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •