+ Reply to Thread
Results 1 to 5 of 5

Macro to Combine Files then VLookup

  1. #1
    Registered User
    Join Date
    05-22-2021
    Location
    US
    MS-Off Ver
    Excel 365
    Posts
    87

    Macro to Combine Files then VLookup

    I need a macro to that will combine 2 files, then add the Region from a 3rd file. The only way I know to do this is to do Vlookup and copy the formula down. I'm sure there is a way to do this using a loop that would make the macro more efficient. Details are below.

    1) Copy data on ServiceArea1.xlsx (A2:Z to the end of data) onto ServiceArea2.xlsx to the next available row.
    2) Add the Region Name onto ServiceArea2 (the combined file) in column O using the data from RegionList.xlsx (3rd file that is only used for pulling in the Region Name).
    ServiceArea2.xlsx - Column N is Region ID, Column O - column to add Region Name from RegionList.xlsx
    RegionList.xlsx - Column M is Region ID, Column N is Region Name


    I appreciate your help.
    Thanks.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,120

    Re: Macro to Combine Files then VLookup

    It would be helpful if you could upload small samples of the three files.



    Please attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    05-22-2021
    Location
    US
    MS-Off Ver
    Excel 365
    Posts
    87

    Re: Macro to Combine Files then VLookup

    I have attached the files:
    ServiceArea1 - Copy this data onto ServiceArea2
    ServiceArea2 - At the end, this file will have data from ServiceArea1 and ServiceArea2; along with column O completed with the Region Names
    RegionList - This is file the Region Name is pulled from by Region ID
    ServiceArea2_EndResult - File just showing what ServiceArea2 file would like after adding data from ServiceArea1 and Region Names


    I appreciate your help.
    Attached Files Attached Files

  4. #4
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MSO Home and Business 2024
    Posts
    7,569

    Re: Macro to Combine Files then VLookup

    For starters. Change Path & Path2 to suit.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by bakerman2; 07-01-2025 at 07:00 AM.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  5. #5
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    15,072

    Re: Macro to Combine Files then VLookup

    Another Option...All books open...
    Please Login or Register  to view this content.
    Good Luck...
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

+ 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. Macro to combine 2 files and add columns(which has Vlookup formulas in)
    By Aredeekay in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-09-2019, 07:42 AM
  2. [SOLVED] Macro to combine multiple (small) files into one file
    By sherylt13 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-05-2017, 08:57 PM
  3. Mac macro to combine all excel files in a folder
    By koosh1986 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-26-2015, 10:54 PM
  4. Combine Files Using Vlookup
    By Vadimchik in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-06-2014, 07:55 AM
  5. Macro to combine and clean multiple files
    By micahjb in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-12-2013, 07:16 PM
  6. Macro to combine several excel files
    By prazumov in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-16-2013, 02:21 AM
  7. Macro formula to combine 2 excel files into 1
    By ecedillo in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-28-2009, 12:58 PM

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