+ Reply to Thread
Results 1 to 5 of 5

VLookup error

  1. #1
    Registered User
    Join Date
    05-19-2006
    Posts
    2

    VLookup error

    I get error 1004; "Unable to get the VLookup property of the WorksheetFunction class" on the following line of code:

    myHoliday = Application.WorksheetFunction.VLookup(myDate, Worksheets("Supporting Sheet").Range("PayPeriod"), 3)

    I'm running Excel 2002. Any suggestions?

  2. #2
    Ken Hudson
    Guest

    RE: VLookup error

    Hi,
    When I have used VLOOKUP in VB, I use the following:

    Range("A1") = "=VLookup(MyDate, 'Supporting Sheet'!PayPeriod, 3)"

    You might try that code.
    --
    Ken Hudson


    "ricm9" wrote:

    >
    > I get error 1004; "Unable to get the VLookup property of the
    > WorksheetFunction class" on the following line of code:
    >
    > -myHoliday = Application.WorksheetFunction.VLookup(myDate,
    > Worksheets("Supporting Sheet").Range("PayPeriod"), 3)-
    >
    > I'm running Excel 2002. Any suggestions?
    >
    >
    > --
    > ricm9
    > ------------------------------------------------------------------------
    > ricm9's Profile: http://www.excelforum.com/member.php...o&userid=34613
    > View this thread: http://www.excelforum.com/showthread...hreadid=543865
    >
    >


  3. #3
    Chip Pearson
    Guest

    Re: VLookup error

    You'll get that error if VLOOKUP doesn't find a match. Instead,
    use

    Dim myHoldiday As Variant
    myHoliday = Application.VLookup(myDate, _
    Worksheets("Supporting Sheet").Range("PayPeriod"), 3)-
    If IsError(myHoliday) = True Then
    ' not found
    End IF


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com





    "ricm9" <[email protected]>
    wrote in message
    news:[email protected]...
    >
    > I get error 1004; "Unable to get the VLookup property of the
    > WorksheetFunction class" on the following line of code:
    >
    > -myHoliday = Application.WorksheetFunction.VLookup(myDate,
    > Worksheets("Supporting Sheet").Range("PayPeriod"), 3)-
    >
    > I'm running Excel 2002. Any suggestions?
    >
    >
    > --
    > ricm9
    > ------------------------------------------------------------------------
    > ricm9's Profile:
    > http://www.excelforum.com/member.php...o&userid=34613
    > View this thread:
    > http://www.excelforum.com/showthread...hreadid=543865
    >




  4. #4
    Registered User
    Join Date
    05-19-2006
    Posts
    2
    Now I get error 2042. What does this error mean?

    I have adjusted the values such that there will always be a match, but that doesn't seem to help.

    Here is the action I want:
    Given a supplied date value, I am trying to find the row who's date matches in column 'A', and then return a corresponding value in column 'C'.

    What a I doing wrong?

  5. #5
    Chip Pearson
    Guest

    Re: VLookup error

    A 2042 error is the same as #N/A error. It means VLOOKUP didn't
    find what it was looking for. You might have numbers formatted as
    text or special characters in the cell.



    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com


    "ricm9" <[email protected]>
    wrote in message
    news:[email protected]...
    >
    > Now I get error 2042. What does this error mean?
    >
    > I have adjusted the values such that there will always be a
    > match, but
    > that doesn't seem to help.
    >
    > Here is the action I want:
    > Given a supplied date value, I am trying to find the row who's
    > date
    > matches in column 'A', and then return a corresponding value in
    > column
    > 'C'.
    >
    > What a I doing wrong?
    >
    >
    > --
    > ricm9
    > ------------------------------------------------------------------------
    > ricm9's Profile:
    > http://www.excelforum.com/member.php...o&userid=34613
    > View this thread:
    > http://www.excelforum.com/showthread...hreadid=543865
    >




+ 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