+ Reply to Thread
Results 1 to 7 of 7

Macro to match cells and import data from source file

  1. #1
    Forum Contributor
    Join Date
    03-08-2011
    Location
    London
    MS-Off Ver
    Work Office 365 Home 2019
    Posts
    427

    Macro to match cells and import data from source file

    Hi Folks,

    I have two workbooks. One is a template the second is source data. Not everything in the template will necessarily be in the source data (the tab in both source and template is called "Generated Question Set")

    What I'd like to do is match the value in column B and if it exists within column B of the source data, import the values in column D and E from source to template.

    This is the template:
    Template.jpg

    This is the source data:
    Source Data.jpg

    As you can see, items 5.1, 5.2 and 6.1 are not included in the source data. Therefore, only the values in 5.3, 5.4 and 5.5 would be copied from source to template.

    I'd also like it so when the macro (let's call it "importdata ()") is activated, it opens an explorer window so the user can select the source data file.

    Anyone got any bright ideas on how I might achieve this?

    Many thanks

    Terry
    Last edited by MagicMan; 11-23-2017 at 11:38 AM. Reason: Forgot tab name

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Macro to match cells and import data from source file

    Open your destination workbook that contains the template and place this macro in a regular module and run the macro from there.
    Please Login or Register  to view this content.
    Save the workbook as a macro-enabled file.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Forum Contributor
    Join Date
    03-08-2011
    Location
    London
    MS-Off Ver
    Work Office 365 Home 2019
    Posts
    427

    Re: Macro to match cells and import data from source file

    Hey Mumps,

    That looks good but I'm encountering a problems inasmuch as it won't import the data. Could that be because the values in column B in the 'destination' workbook are generated by formula rather than as direct inputs?

    The File called 3rd Party Supplier Assessment - Stripped Template (supplier name) is the destination workbook
    The File called 3rd Party Supplier Assessment - Stripped Test Company is the source workbook with some dummy data inserted.

    You can ignore many of the tabs as they're used to feed the generated queston set dependent upon the answers given in the Preliminary Question Set tab.
    Last edited by MagicMan; 11-23-2017 at 04:29 PM.

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Macro to match cells and import data from source file

    I didn't realize that you had formulas in columns A and B. Assuming that the data in column B will always be numeric, try:
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    03-08-2011
    Location
    London
    MS-Off Ver
    Work Office 365 Home 2019
    Posts
    427

    Re: Macro to match cells and import data from source file

    Mumps!

    I don't know whether to kiss you, fall at your feet or just offer to hand over my first born!

    you're a absolute star and Well Deserved Reputation has been added.

    Magic Man

  6. #6
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Macro to match cells and import data from source file

    Wow! Now that was quite a compliment!! Thank you for the rep and it was my pleasure to help.

  7. #7
    Forum Contributor
    Join Date
    03-08-2011
    Location
    London
    MS-Off Ver
    Work Office 365 Home 2019
    Posts
    427

    Re: Macro to match cells and import data from source file

    I do have other plans for the same sheet, so watch this space .....

+ 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 does not wait for data to import from an outside source
    By prent327 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-07-2017, 08:48 AM
  2. Replies: 0
    Last Post: 05-28-2014, 02:45 AM
  3. Copy, edit and save workbook to same location as source data file, not macro file.
    By Jasonhouse in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-02-2014, 09:01 AM
  4. [SOLVED] MACRO: Store name of selected file as string w/ import data file dialog box
    By AnnieMcken in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-13-2013, 02:13 PM
  5. Replies: 0
    Last Post: 08-09-2013, 05:54 PM
  6. [SOLVED] Macro - Master file to import data from another open file with variable file name
    By jdodz in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-10-2012, 10:56 PM
  7. Import External Data Source File Location Changed
    By Louise in forum Excel General
    Replies: 3
    Last Post: 01-04-2006, 10:50 AM

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