+ Reply to Thread
Results 1 to 4 of 4

Thread: worksheetfunction.vlookup returning run-time error (1004)

  1. #1
    Registered User
    Join Date
    11-13-2010
    Location
    Springfield, IL
    MS-Off Ver
    Excel 2007
    Posts
    36

    worksheetfunction.vlookup returning run-time error (1004)

    In 10 minutes of searching the forums, I didn't find an answer to this question:

    Sub DeCode()
    
    'get the length of the text string in the textbox (codebox)
    CodeString = Worksheets("DeCoder").OLEObjects("Codebox").Object.Text
    CodeLength = Len(CodeString)
    
    For i = 1 To CodeLength
        BinaryString = Application.WorksheetFunction.VLookup(Mid(CodeString, i, 1), Range("Binary"), 3, False)
        MsgBox BinaryString
    Next i
    
    End Sub
    When I run this code, I get an error message, "Unable to get the VLookup property of the WorksheetFunction class". I know the individual arguments in that vlookup code are all correct; I can manipulate them each individually in the sub routine. Why can't excel find the Vlookup property (and why does it think its a property, not a method)?

    thank you!
    Last edited by Mervil; 11-19-2010 at 12:23 AM.

  2. #2
    Forum Moderator Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2007
    Posts
    5,953

    Re: worksheetfunction.vlookup returning run-time error (1004)

    Hi Mervil,

    Try just "Application.Vlookup" instead of "Application.WorksheetFunction.Vlookup"

  3. #3
    Registered User
    Join Date
    11-13-2010
    Location
    Springfield, IL
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: worksheetfunction.vlookup returning run-time error (1004)

    Ok. What the heck. That worked! But WHY did that work? I thought vlookup was a worksheetfunction.

  4. #4
    Forum Moderator Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2007
    Posts
    5,953

    Re: worksheetfunction.vlookup returning run-time error (1004)

    I think it technically is part of WorksheetFunction, but doesn't work when that is added to the code. ::shrug::

    Just something I've come across when trying myself.

+ 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.2.0