+ Reply to Thread
Results 1 to 6 of 6

Error accessing a function within a macro

  1. #1
    Registered User
    Join Date
    05-31-2006
    Posts
    58

    Error accessing a function within a macro

    I know I am missing something small but I can't figure it out. I have tested this in the workbook and it functions properly but not within the macro.

    I tried the following to access the worksheet function and received 'Runtime error 1004: Unable to get the VLookup property of the WorksheetFunction class'.

    Please Login or Register  to view this content.
    Thinking I needed to tie it to the workbook I tried the following and received 'Runtime error: 438: Object doesn't support this property or method.'

    Please Login or Register  to view this content.
    Please point out what I am missing.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Error accessing a function within a macro

    Assuming "WW4301" is a literal string,
    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    05-31-2006
    Posts
    58

    Re: Error accessing a function within a macro

    That's what I was missing. Why does the range need to be defined in such a way?

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Error accessing a function within a macro

    A literal string is not a range. You wouldn't expect to write
    Please Login or Register  to view this content.
    and have it work. You'd need to write
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    05-31-2006
    Posts
    58

    Re: Error accessing a function within a macro

    Got it. After adjusting my code I am receiving the same error on an identical piece except with a different range. The first If statement processes correctly but the second provides the same 'WorksheetFunction class' error. I have marked them and another section I predict will provide an error in red as well as posting the entire code.

    The purpose of this is to use two values from an external report, find the index and insert a third value from the report at this point. I eventually will need to add a fourth value from the report adjacent to the index but I am doing this in chunks.

    Please Login or Register  to view this content.

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Error accessing a function within a macro

    The first match will return an error or a number, not 0 or a number. You either need to handle the error, or use another method, like Find.

+ 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