+ Reply to Thread
Results 1 to 4 of 4

Help with VBA Code for Performing Vlookups Across Two Workbooks

  1. #1
    Registered User
    Join Date
    09-20-2017
    Location
    Erie,PA, USA
    MS-Off Ver
    MS Office 2016
    Posts
    7

    Red face Help with VBA Code for Performing Vlookups Across Two Workbooks

    I have written a code that works to perform vlookups across two workbooks I tested the code and I know it works if I remove the lines "Do Until IsEmpty(lookFor)" and "Loop" for performing a Vlookup for Cell B3, however I would like the code to be performed down the whole column. So my first question is am I using the Loop function correctly in the correct spot, if not how should I be using it? If I am using the Loop function correctly then how can I make this code more efficient, is there a better code for what I am trying to do? Every time I try to run my code excel crashes so I don't know if the code is just wrong or if its just too taxing on the program. Any help would be greatly appreciated!! :D

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Help with VBA Code for Performing Vlookups Across Two Workbooks

    Ad 1. 'book2NamePath'

    If 'ThisWorkbook' is in e.g. "C:\Temp" then 'ThisWorkbook.Path' = "C:\Temp", without "\" at the end,

    then if "book2NamePath = ThisWorkbook.Path & "C:\Users\212549241\Documents\Projects\BulletTrain Austin" & book2Name", then we have mishmash:

    "C:\TempC:\Users\212549241\Documents\Projects\BulletTrain Austin2017-10_Report 02 Bullet Train - 11-13a - new Saides - Lucio Ref 000000 - Rio (2).xlsm"

    and additionally between 'BulletTrain Austin" and 'book2Name' there is missing next "\".


    Ad 2. 'Workbooks.Open (book2NamePath)'

    Not 'Workbooks.Open (book2NamePath)' but 'Workbooks.Open book2NamePath' or Workbooks.Open Filename:=book2NamePath, without parentheses.
    With parentheses if is object assigning 'Set wrkb=' ==> Set wrkb = Workbooks.Open(book2NamePath)


    And then ... there is ... something ... something incomprehensible ... ... sorry ...

  3. #3
    Registered User
    Join Date
    09-20-2017
    Location
    Erie,PA, USA
    MS-Off Ver
    MS Office 2016
    Posts
    7

    Re: Help with VBA Code for Performing Vlookups Across Two Workbooks

    Thanks for your response! But, as I said above that part of my code worked just fine for me. While continuing to research how to fix it I can tell that where my code went wrong is the loop, however I can't figure out how to fix the loop so it just reruns the vlookup for every cell down my column. Any help you could give related to fixing the loop would be awesome!! I am still really new to VBA and I don't really have a proper grasp on how to use loops.

  4. #4
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Help with VBA Code for Performing Vlookups Across Two Workbooks

    You must have a counter inside the loop, try it that way:
    Please Login or Register  to view this content.
    Last edited by mjr veverka; 11-21-2017 at 06:16 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Version of Mac not performing PC VBA code?
    By MarvinP in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 3
    Last Post: 06-16-2017, 05:27 AM
  2. Simplifying formula with 30 VLOOKUPs to externally linked workbooks
    By lincolnsmiff in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-31-2016, 02:02 AM
  3. VBA code works but isn't performing
    By shmowell in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-14-2016, 06:06 PM
  4. Checkbox VB code isnt performing properly
    By mshaneweaver in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-20-2014, 03:38 PM
  5. performing sum function using code
    By aman1234 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-10-2011, 03:37 PM
  6. performing Multiple vlookups
    By mojobaabby in forum Excel General
    Replies: 3
    Last Post: 05-10-2011, 06:45 PM

Tags for this Thread

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