Consulting

Results 1 to 4 of 4

Thread: Solved: lookup date

  1. #1

    Solved: lookup date

    Can someone assist with a code that will look in column B (Range B11:B250) and determine if a date exist. If so, go to that cell with requested date. If not, then exit sub.

    Thank you for your assistance.

  2. #2
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,362
    Location
    Maybe:
    [VBA]Option Explicit

    Sub exa()
    Dim ret As String
    Dim arySplit() As String
    Dim rng As Range
    Dim dtmLookFor As Date

    ret = Application.InputBox( _
    "Enter the date in the following format: m,d,yyyy" & vbCrLf & _
    "That is, a one or two digit number for the month, followed by a comma," & _
    " followed by a one or two digit number for the day, followed by a comma," & _
    " followed by a four digit number for the year.", "Enter Date", , , , , , 2)

    If InStr(1, ret, ",") Then
    arySplit = Split(ret, ",")
    If UBound(arySplit) = 2 Then
    dtmLookFor = DateSerial(Trim(arySplit(2)), _
    Trim(arySplit(0)), _
    Trim(arySplit(1)))
    Set rng = Range("B11:B250").Find(dtmLookFor, Range("B250"), xlFormulas, xlWhole)
    If Not rng Is Nothing Then
    Application.Goto rng, True
    End If
    End If
    End If
    End Sub[/VBA]

  3. #3
    thank you GTO

  4. #4
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,362
    Location
    You are most welcome :-)

Posting Permissions

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