+ Reply to Thread
Results 1 to 4 of 4

VLookup not returning expected result

  1. #1
    Registered User
    Join Date
    03-15-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2010
    Posts
    25

    VLookup not returning expected result

    The following code is supposed to return the value from column B of MOCK.xlsm SECTION1 but instead I get an #N/A. The full macro is in the attached MOCK.xlsm. Machine1.xlsx is one of the files it will output from the TestFile.xlsx so you can see the result without having to run it. Both records under Section 1 of Machine1.xlsx should have been replaced by their coresponding value in Column B. What am I doing wrong???

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by tenscourts; 03-21-2012 at 11:09 AM.

  2. #2
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: VLookup not returning expected result

    Maybe try changing this row:
    Please Login or Register  to view this content.
    to this:
    Please Login or Register  to view this content.
    Please consider:

    Thanking those who helped you. Click the star icon in the lower left part of the contributor's post and add Reputation.
    Cleaning up when you're done. Mark your thread [SOLVED] if you received your answer.

  3. #3
    Registered User
    Join Date
    03-15-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2010
    Posts
    25

    Re: VLookup not returning expected result

    When I make the changes I get a "Object variable or With block variable not set" error on the line "Loop While Not C Is Nothing And C.Row <> FirstRow" and I still don't think it's returning the expected value based on the way the file looks at the point of the error. It is still showing #N/A for both records that were marked with a 1.

  4. #4
    Registered User
    Join Date
    03-15-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2010
    Posts
    25

    Re: VLookup not returning expected result

    after looking at it again by changing c to c.row as abousetta recommended it does appear to cycle through all the records where as before it only did one. so that is an improvement. the problem is after the change i get the runtime error i mentioned above and it still returns #N/A which makes me think there is somethign wrong with my VLOOKUP. Anyone got any ideas?

+ 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