+ Reply to Thread
Results 1 to 8 of 8

worksheetfunction vlookup

  1. #1
    Registered User
    Join Date
    03-15-2007
    Posts
    50

    worksheetfunction vlookup

    I have a macro that needs to do a vlookup. When I use the following code:

    Please Login or Register  to view this content.
    I get the error "Unable to get the VLookup property of the worksheetfunction class"

    codem is a variable I want to assign the lookup value to so I can use it in other formulas.

    Any ideas how to solve?

    Thanks

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,525
    Here's something that I have in one of my workbooks

    Please Login or Register  to view this content.

  3. #3
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    I had a similar problem and remember reading somewhere that an "On Error Resume Next" statement at the top of the code should eliminate that problem...

    can't remember the reasoning behind it though...if you search the internet for that error, you may find it.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  4. #4
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,454
    hi,

    Is events a named range? If so replace with

    Please Login or Register  to view this content.
    hth


    dave

  5. #5
    Registered User
    Join Date
    03-15-2007
    Posts
    50
    Thanks for all the input. I tried the changes suggested with no change in the error. I compared my code to that in Davesexcel's post and I don't see any difference. It almost seems as if my code doesn't recognize what to do with the vlookup. Is there a module that I have to ensure is loaded?

  6. #6
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    did you try adding the error handling code I suggested.

    Here is the place that explains it: http://www.cpearson.com/Excel/Callin...onsFromVBA.htm

    Chip also explains that you can eliminate the Worksheetfunction propery....and simply use

    Please Login or Register  to view this content.
    and here is another place that mentions it and also an alternative to Vlookup that might work better for you:

    http://www.theofficeexperts.com/foru...hp/t-1062.html
    Last edited by NBVC; 04-25-2007 at 08:57 AM.

  7. #7
    Forum Contributor
    Join Date
    08-28-2006
    Posts
    280
    Hey Irish,

    I had an instance several months ago along the same lines and after some extensive research found out the the Worksheet Function will not work or will at best be very flaky in a search or match situation. The best alternative I found was to use the Application.Vlookup option. Worked fine for me.

    Dean

  8. #8
    Registered User
    Join Date
    03-15-2007
    Posts
    50
    Yes, I put in the error handling you suggested and I got the same error until I eliminated the "Worksheetfunction" from the code. Once I did that, my variable was set to an error value as if it did not find the data in the range. The problem is, that if I use VBA to grab a cell and set its' value to equal that lookup formula, it works and finds the data I am looking for.

    So, the formula works and finds the correct data if I plug the formula into a cess. If I set a variable to equal that lookup, it doesn't fine the data??? I would like to try the .Find, but I am fairly clueless as to how that works. I have read all of the examples, but I don't understand how it's working. Can someone explain what this code (from the example) is doing?

    Please Login or Register  to view this content.

+ 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