+ Reply to Thread
Results 1 to 5 of 5

Macro that will transfer data into single workbook

  1. #1
    Registered User
    Join Date
    07-20-2016
    Location
    Pittsburgh
    MS-Off Ver
    2013
    Posts
    3

    Macro that will transfer data into single workbook

    I'm still very new to macros so I’m not sure if a macro can be done for this.

    I have a primary workbook (Workbook A) with 30 columns with titles. Data from other workbooks needs to be imported into Workbook A.
    The issue is, the columns from the various workbooks do not match the columns in Workbook A. For example the other spreadsheets have like 15 columns with titles that aren’t exactly the same as Workbook A’s titles.

    Some of the data will match up to Workbook A but some of Workbook A’s columns will need to have data manually input into them.

    Also, I need each new set of data that is imported to go to the next available empty row of Workbook A instead of copying over the existing data in the spreadsheet. And if the other spreadsheets have some rows without data can the macro skip those rows and go to the next row with data?

    I’ve worked with macros that completely transpose a tab and I was able to work with a code that will just copy and paste the data straight into the other sheet exactly as it is, but this is much more complex as the data isn't going to the same corresponding cell in the workbook.

    I've attached an Excel file that just gives an example of what I mean when I say that Workbook A's titles don't match up with the titles of the data I'm trying to import and some of it needs to be entered manually.
    Attached Files Attached Files

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Macro that will transfer data into single workbook

    This is certainly doable, but it would help a lot to include a sample workbook A and sample workbook B with enough non-sensitive data to demonstrate the concept. It is good to have the "mapping" you've provided in this workbook, But I don't think people are going to take the time to set up the workbooks and populate them with data.

    One other question. Do you want to run the macro from workbook A (which you might not want to do if someone gives you a new workbook A every day), or do you want a separate workbook the opens A then opens B and appends B's data into A?
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Registered User
    Join Date
    07-20-2016
    Location
    Pittsburgh
    MS-Off Ver
    2013
    Posts
    3

    Re: Macro that will transfer data into single workbook

    Attached are some sample workbooks. There's a lot more data that is listed in the real version of the "Example" workbook, but I didn't think it necessary to create an exact replica.
    Workbook A is the main workbook and a new Workbook A is only created about twice a year so it is fine if the the macro is run from Workbook A. The users would probably find it confusing if it wasn't.

    Sorry for the delay in my response. I was bogged down in another project.
    I appreciate any direction someone can give me.

    Thanks in advance!
    Attached Files Attached Files

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Macro that will transfer data into single workbook

    Example rows 7-9 are dupes of rows 1-3 - is that the situation?

    Oops! Nevermind

    But are the headers the same in both?
    Last edited by xladept; 09-11-2016 at 11:54 AM.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  5. #5
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Macro that will transfer data into single workbook

    Here is my shot at it. I display the data you want in an Excel Table. Excel tables have a lot of benefits: http://www.utteraccess.com/wiki/inde...ables_in_Excel. The one I'm using here is that tables know how big they are, so it's easy to clear them out.

    I included a control panel page where you can tell the program where the data file is located and what it is called. Enter the appropriate data in column B and you are good to go. No need to change any code. There are two places in the code where you have to change the page name in case you change the name from Workbook A to something else. These are marked with comments.

    The Control Panel has two buttons: Copy Data and Clear Table. The Copy Data Button runs the program and appends the data it reads to whatever is in the table. The Clear Table button clears out all the information in the table. I don't know how often you will need to "start from scratch" but you can do it if you need to.
    Attached Files Attached Files

+ 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. [SOLVED] How to transfer data from one workbook to another workbook using Macro
    By kingsdime29x in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-13-2016, 12:27 PM
  2. [SOLVED] Macro to Combine Multiple Workbook Data into Single Target Workbook
    By Jimbo42 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-27-2014, 08:26 PM
  3. Replies: 3
    Last Post: 02-21-2014, 09:05 AM
  4. [SOLVED] need help on a macro to transfer data to another workbook
    By aftonr in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-10-2012, 11:47 AM
  5. Macro to transfer data from one workbook to another
    By Sean Anderson in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 05-16-2011, 01:37 PM
  6. Transfer data fron one workbook to another using macro
    By nachousa in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-11-2010, 11:46 AM
  7. Transfer data fron one workbook to another using macro
    By nachousa in forum Access Programming / VBA / Macros
    Replies: 1
    Last Post: 06-11-2010, 11:45 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