+ Reply to Thread
Results 1 to 3 of 3

Vlookup still not working

  1. #1
    SHIPP
    Guest

    Vlookup still not working

    I am working in Excel 97 and have the following code.

    Private Sub CalcSchedule_Click()

    Dim strCurrentSchedDate As Date
    Dim strLookupDate As String
    Dim strLookupYesNo As String

    Sheets("NON WORKDAY").Select
    Application.Rows("10:232").Select
    Selection.Sort Key1:=Application.Range("A10"), Order1:=xlAscending,
    Header:=xlGuess, _
    OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
    Sheets("Schedule").Select
    strCurrentSchedDate = Cells(7, 3).Value
    Range("A1").Value = strCurrentSchedDate
    Cells(1, 2) = Application.VLookup(strCurrentSchedDate, _
    Worksheets("NON WORKDAY").Range("A10:A500"), 2)

    End Sub

    The problem is that vlookup is returning #N/A. In fact, the date, 01/08/2005
    I am looking up, is located in cell A12 on Worksheet "NON WORKDAY". Does
    anybody know what could be the problem? I have confirmed, by stepping through
    the code, that strCurrentSchedDate contains 01/08/2005.
    --
    M. Shipp

  2. #2
    Tom Ogilvy
    Guest

    Re: Vlookup still not working

    Try this:

    Cells(1, 2) = Application.VLookup(clng(strCurrentSchedDate), _
    Worksheets("NON WORKDAY").Range("A10:A500"), 2)

    --
    Regards,
    Tom Ogilvy




    "SHIPP" <[email protected]> wrote in message
    news:[email protected]...
    > I am working in Excel 97 and have the following code.
    >
    > Private Sub CalcSchedule_Click()
    >
    > Dim strCurrentSchedDate As Date
    > Dim strLookupDate As String
    > Dim strLookupYesNo As String
    >
    > Sheets("NON WORKDAY").Select
    > Application.Rows("10:232").Select
    > Selection.Sort Key1:=Application.Range("A10"), Order1:=xlAscending,
    > Header:=xlGuess, _
    > OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
    > Sheets("Schedule").Select
    > strCurrentSchedDate = Cells(7, 3).Value
    > Range("A1").Value = strCurrentSchedDate
    > Cells(1, 2) = Application.VLookup(strCurrentSchedDate, _
    > Worksheets("NON WORKDAY").Range("A10:A500"), 2)
    >
    > End Sub
    >
    > The problem is that vlookup is returning #N/A. In fact, the date,

    01/08/2005
    > I am looking up, is located in cell A12 on Worksheet "NON WORKDAY". Does
    > anybody know what could be the problem? I have confirmed, by stepping

    through
    > the code, that strCurrentSchedDate contains 01/08/2005.
    > --
    > M. Shipp




  3. #3
    Tom Ogilvy
    Guest

    Re: Vlookup still not working

    One other correction. You are trying to return data from column 2, but only
    have a single column as the lookup range, so you need

    Cells(1, 2) = Application.VLookup(clng(strCurrentSchedDate), _
    Worksheets("NON WORKDAY").Range("A10:B500"), 2)




    --
    Regards,
    Tom Ogilvy

    "Tom Ogilvy" <[email protected]> wrote in message
    news:[email protected]...
    > Try this:
    >
    > Cells(1, 2) = Application.VLookup(clng(strCurrentSchedDate), _
    > Worksheets("NON WORKDAY").Range("A10:A500"), 2)
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    >
    >
    >
    > "SHIPP" <[email protected]> wrote in message
    > news:[email protected]...
    > > I am working in Excel 97 and have the following code.
    > >
    > > Private Sub CalcSchedule_Click()
    > >
    > > Dim strCurrentSchedDate As Date
    > > Dim strLookupDate As String
    > > Dim strLookupYesNo As String
    > >
    > > Sheets("NON WORKDAY").Select
    > > Application.Rows("10:232").Select
    > > Selection.Sort Key1:=Application.Range("A10"), Order1:=xlAscending,
    > > Header:=xlGuess, _
    > > OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
    > > Sheets("Schedule").Select
    > > strCurrentSchedDate = Cells(7, 3).Value
    > > Range("A1").Value = strCurrentSchedDate
    > > Cells(1, 2) = Application.VLookup(strCurrentSchedDate, _
    > > Worksheets("NON WORKDAY").Range("A10:A500"), 2)
    > >
    > > End Sub
    > >
    > > The problem is that vlookup is returning #N/A. In fact, the date,

    > 01/08/2005
    > > I am looking up, is located in cell A12 on Worksheet "NON WORKDAY". Does
    > > anybody know what could be the problem? I have confirmed, by stepping

    > through
    > > the code, that strCurrentSchedDate contains 01/08/2005.
    > > --
    > > M. Shipp

    >
    >




+ 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