+ Reply to Thread
Results 1 to 6 of 6

Run-time Error 1004: Unable to get the VLookup property of the WorksheetFunction class

  1. #1
    Registered User
    Join Date
    12-08-2012
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2010
    Posts
    3

    Run-time Error 1004: Unable to get the VLookup property of the WorksheetFunction class

    My code is below:-

    Please Login or Register  to view this content.
    I am getting the error I mentioned in the subject. I am trying to fetch a value from the 7th column (i.e. column H) of "myRange" after matching the value of "SystemType" in the first column (i.e. column B). Current values of SystemType is of String data type and the value of Charge is of Integer.

    I searched the web and found many mentions of this problem. But I could find only 2 solutions. In both cases the code writers were matching "date" data type. It seems there is a difference between excel and VB macro for that data type. The solutions suggested changing the "date" type to "Range" type and the macro worked after that.

    But in my case it is not so. I am matching & fetching "variant" type data. I am using MS Excel 2010 & MS VBA 7. Thanks very much in advance.
    Last edited by davesexcel; 12-08-2012 at 09:04 AM.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646
    Have you tried declaring SystemType as String?
    If posting code please use code tags, see here.

  3. #3
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Run-time Error 1004: Unable to get the VLookup property of the WorksheetFunction class

    You appear to not have declared I which sets the value of your systemtype, does systemtype actually have a value in your code? Secondly if it does, is the value actually in the range you're looking up from?

  4. #4
    Registered User
    Join Date
    12-08-2012
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Run-time Error 1004: Unable to get the VLookup property of the WorksheetFunction class

    Hi Norie - Thanks very much. Yes, have tried defining SystemType as String. Same result - Error 1004.

    Hi Kyle123 - Thanks very much. I had declared "I" as integer though I did not paste that particular "Dim" statament into the snippet I pasted in Excelforum thread. And yes, SystemType has a string value (B1, Y4, B7, Y3....etc are the values in different rows of myRange).

    To all reading this thread -- The beauty is that the same VLookup works perfectly inside the excel worksheet. All looked up values are proper and further calculations based ont the looked up values are also correct in a worksheet. It just that it does not work in the VBA macro.

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Run-time Error 1004: Unable to get the VLookup property of the WorksheetFunction class

    Can you attach a sample workbook?

  6. #6
    Registered User
    Join Date
    12-08-2012
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Run-time Error 1004: Unable to get the VLookup property of the WorksheetFunction class

    Hi Nori, Thanx very much. Teh problem is solved. There was a bug in my code which made SystemType to have no value. Thanx for the time & effort.

+ 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