+ Reply to Thread
Results 1 to 6 of 6

Copy data from Workbook 2 that matches option in Workbook 2

  1. #1
    Registered User
    Join Date
    12-15-2014
    Location
    Wales, UK
    MS-Off Ver
    365
    Posts
    66

    Copy data from Workbook 2 that matches option in Workbook 2

    I'm very new to VBA coding, so don't understand all the options yet, but I can read the code if someone can please help with VBA code for a macro to do the following:

    Workbook 1 can have different options for regions, example: Workbook("1").Sheet("1").Cell(A2), can be "Inland" or "WC", etc.
    Whichever region it reads should recall the list in Workbook("2").Sheet("List") and the corresponding data for that region which looks like the following:

    A B C D E F G H I J K
    1 INLAND KZN EC WC
    2 GC57 Lenasia KF05 Family Pietermaritzburg EC06 George WC55 Local Kenridge
    3 GC20 Gallo Manor KF01 Family Kirstens EO08 Express Fiveways WC10 Sea Point

    Example: If WB1 reads "Inland", copy whole list from WB2 "Inland" cells (A2: B[end]) and paste in Workbook("1").Sheet("List").Cell(A2).

    I hope it makes sense and that someone can help, I believe it's fairly easy to code this request.

    Thank you

  2. #2
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,154

    Re: Copy data from Workbook 2 that matches option in Workbook 2

    Hi Simone

    Welcome to the Forum....
    Please attach a sample workbook with a before & after scenario making sure that your desired solution is shown - mock up the results manually if need be. This will enable us to offer the exact code assistance.
    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 star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  3. #3
    Registered User
    Join Date
    12-15-2014
    Location
    Wales, UK
    MS-Off Ver
    365
    Posts
    66

    Re: Copy data from Workbook 2 that matches option in Workbook 2

    Sorry, I see that the posted view in my first message was not as I typed it.
    I've attached both mock-up Workbooks.

    Workbook1.Sheet(Sheet1) has criteria example
    Region Workbook has list of regions
    Copy corresponding list from Region Workbook to Workbook1.sheet(Final).cell(A2)

    The lists for the regions can vary in length, thus I need it to be able to copy to the end of the list please.
    Attached Files Attached Files

  4. #4
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,154

    Re: Copy data from Workbook 2 that matches option in Workbook 2

    This code provides your required result , however, i presume the uploaded sample is not as elaborate as your original file so might need to tweak.
    PS I saved your Workbook 1 as a macro enabled....

    Try to stay away from merged cells.....They always create unnecessary problems.
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    12-15-2014
    Location
    Wales, UK
    MS-Off Ver
    365
    Posts
    66

    Re: Copy data from Workbook 2 that matches option in Workbook 2

    It was a quick mock-up for the data, but I do receive it in merged cells which I also hate to work with.
    After changing it to my specifications it worked perfectly!! Thank you very much

  6. #6
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,154

    Re: Copy data from Workbook 2 that matches option in Workbook 2

    Glad i could help...tx for the rep +

    PS Please mark thread as solved.

+ 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. Import graph from a specific workbook if a cell matches the workbook name
    By hassan88 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-29-2015, 05:11 AM
  2. [SOLVED] Copy data from one workbook to another one if a kriteria matches
    By Joachimjr in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-17-2014, 04:44 AM
  3. Copy data one workbook to another workbook without opening workbook
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-04-2014, 11:28 AM
  4. .Find header and column in another workbook and copy the cell that matches both
    By Ariadust in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-06-2012, 12:15 AM
  5. Replies: 7
    Last Post: 03-29-2011, 06:22 PM
  6. Copy rows when column matches a user input from another workbook
    By cjc155 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-21-2008, 04:33 AM
  7. Replies: 1
    Last Post: 04-01-2006, 03:50 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