+ Reply to Thread
Results 1 to 6 of 6

Find a date in a list

  1. #1
    Leonard615
    Guest

    Find a date in a list

    I have a worksheet with 12 columns of information, one of which is dates
    related to the information. The dates are not in order chronologically. I'd
    like a macro asking the user to enter his desired date and have the macro
    take him to the first occurrence of that date. Tried using Find, but haven't
    been able to figure out how to make it work for dates. Any suggestions would
    be greatly appreciated.

  2. #2
    Martin P
    Guest

    RE: Find a date in a list

    If the dates are in column A, enter the follwing in cell A1:
    =TEXT(A1,"dd")&TEXT(A1,"mmmm")&TEXT(A1,"yyyy")
    Copy down.
    Enter something like 19december2004 in the Find What field. Remember to
    choose Values under Options.


    "Leonard615" wrote:

    > I have a worksheet with 12 columns of information, one of which is dates
    > related to the information. The dates are not in order chronologically. I'd
    > like a macro asking the user to enter his desired date and have the macro
    > take him to the first occurrence of that date. Tried using Find, but haven't
    > been able to figure out how to make it work for dates. Any suggestions would
    > be greatly appreciated.


  3. #3
    Leonard615
    Guest

    RE: Find a date in a list

    Thank you. This does work, but for other reasons I would like to "Find"
    using just the date. Is there another way to do this without additional
    cells or formulae?

    "Martin P" wrote:

    > If the dates are in column A, enter the follwing in cell A1:
    > =TEXT(A1,"dd")&TEXT(A1,"mmmm")&TEXT(A1,"yyyy")
    > Copy down.
    > Enter something like 19december2004 in the Find What field. Remember to
    > choose Values under Options.
    >
    >
    > "Leonard615" wrote:
    >
    > > I have a worksheet with 12 columns of information, one of which is dates
    > > related to the information. The dates are not in order chronologically. I'd
    > > like a macro asking the user to enter his desired date and have the macro
    > > take him to the first occurrence of that date. Tried using Find, but haven't
    > > been able to figure out how to make it work for dates. Any suggestions would
    > > be greatly appreciated.


  4. #4
    Rowan Drummond
    Guest

    Re: Find a date in a list

    Try:

    Sub test()
    Dim strDate As String
    Dim dDate As Date
    Dim fndDate As Range
    strDate = InputBox("Enter the Date to Find")
    On Error Resume Next
    dDate = CDate(strDate)
    On Error GoTo 0
    If Not dDate = Empty Then
    With Sheets(1).Columns(1) 'change sheet and column as required
    Set fndDate = .Find(dDate)
    End With
    If Not fndDate Is Nothing Then
    fndDate.Activate 'or whatever
    Else
    MsgBox "Date not found"
    End If
    Else
    MsgBox "You must enter a valid date"
    End If
    End Sub

    Hope this helps
    Rowan

    Leonard615 wrote:
    > Thank you. This does work, but for other reasons I would like to "Find"
    > using just the date. Is there another way to do this without additional
    > cells or formulae?
    >
    > "Martin P" wrote:
    >
    >
    >>If the dates are in column A, enter the follwing in cell A1:
    >>=TEXT(A1,"dd")&TEXT(A1,"mmmm")&TEXT(A1,"yyyy")
    >>Copy down.
    >>Enter something like 19december2004 in the Find What field. Remember to
    >>choose Values under Options.
    >>
    >>
    >>"Leonard615" wrote:
    >>
    >>
    >>>I have a worksheet with 12 columns of information, one of which is dates
    >>>related to the information. The dates are not in order chronologically. I'd
    >>>like a macro asking the user to enter his desired date and have the macro
    >>>take him to the first occurrence of that date. Tried using Find, but haven't
    >>>been able to figure out how to make it work for dates. Any suggestions would
    >>>be greatly appreciated.


  5. #5
    Leonard615
    Guest

    Re: Find a date in a list

    This worked perfectly. Thanks so much for the help.

    "Rowan Drummond" wrote:

    > Try:
    >
    > Sub test()
    > Dim strDate As String
    > Dim dDate As Date
    > Dim fndDate As Range
    > strDate = InputBox("Enter the Date to Find")
    > On Error Resume Next
    > dDate = CDate(strDate)
    > On Error GoTo 0
    > If Not dDate = Empty Then
    > With Sheets(1).Columns(1) 'change sheet and column as required
    > Set fndDate = .Find(dDate)
    > End With
    > If Not fndDate Is Nothing Then
    > fndDate.Activate 'or whatever
    > Else
    > MsgBox "Date not found"
    > End If
    > Else
    > MsgBox "You must enter a valid date"
    > End If
    > End Sub
    >
    > Hope this helps
    > Rowan
    >
    > Leonard615 wrote:
    > > Thank you. This does work, but for other reasons I would like to "Find"
    > > using just the date. Is there another way to do this without additional
    > > cells or formulae?
    > >
    > > "Martin P" wrote:
    > >
    > >
    > >>If the dates are in column A, enter the follwing in cell A1:
    > >>=TEXT(A1,"dd")&TEXT(A1,"mmmm")&TEXT(A1,"yyyy")
    > >>Copy down.
    > >>Enter something like 19december2004 in the Find What field. Remember to
    > >>choose Values under Options.
    > >>
    > >>
    > >>"Leonard615" wrote:
    > >>
    > >>
    > >>>I have a worksheet with 12 columns of information, one of which is dates
    > >>>related to the information. The dates are not in order chronologically. I'd
    > >>>like a macro asking the user to enter his desired date and have the macro
    > >>>take him to the first occurrence of that date. Tried using Find, but haven't
    > >>>been able to figure out how to make it work for dates. Any suggestions would
    > >>>be greatly appreciated.

    >


  6. #6
    Rowan Drummond
    Guest

    Re: Find a date in a list

    You're welcome.

    Leonard615 wrote:
    > This worked perfectly. Thanks so much for the help.
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1