+ Reply to Thread
Results 1 to 12 of 12

Copying data from other workbooks and pasting into master workbook

  1. #1
    Registered User
    Join Date
    07-05-2013
    Location
    South Carolina, USA
    MS-Off Ver
    Excel 2007
    Posts
    21

    Question Copying data from other workbooks and pasting into master workbook

    OK so I have tried everything I can think of to modify this macro I pulled from the net but I keep getting errors. I don’t know where I am going wrong in addition to my limited knowledge of coding macros has really put me in a bind. I need this macro to prompt me to select a workbook(s) then copy everything on Sheet2 to my master workbook until all of the source workbooks have been processed into the master.

    Here is my code. I have reverted it back to the original I copied from the net because I butchered the original too much.
    I have also included my sample data.

    Please Login or Register  to view this content.
    UNSPSC_v14_0801.xlsUNSPSC_v15_1101.xlsMaster.xlsx

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    re: Copying data from other workbooks and pasting into master workbook

    You did not specify what problems you encountered with the code. Did you get any error? If so, which line of the code? If there is no error, what is not working?
    You are coping from each book the second sheet in to sheet1, but if the index of sheets have changed, the code may copy the wrong data
    Last edited by AB33; 07-14-2013 at 04:56 PM.

  3. #3
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    re: Copying data from other workbooks and pasting into master workbook

    First correction

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    07-05-2013
    Location
    South Carolina, USA
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Copying data from other workbooks and pasting into master workbook

    Nope not error, The macro sems to let me select the file, then the screen flashes, and the macro ends. It never goes past this line:
    I got it past this line once but it thew an out of range error. Sorry I didnt make note of the actual error code.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    07-05-2013
    Location
    South Carolina, USA
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Copying data from other workbooks and pasting into master workbook

    @ AB33 - Both my original line and yours seemed function properly but nothing actual goes anywhere after that. Just terminates the macro.

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Copying data from other workbooks and pasting into master workbook

    Well, There are few issues with the code.
    You said you want to copy everything, yet
    Cells(Rows.Count, "AD").Select
    selects all rows in column AD only. You have also few other lines which may either be unnecessary or could be written differently.
    What column/ rows do you want to copy? Do you have sheets called sheet1 and sheet2 in your data?
    Last edited by AB33; 07-14-2013 at 05:13 PM.

  7. #7
    Registered User
    Join Date
    07-05-2013
    Location
    South Carolina, USA
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Copying data from other workbooks and pasting into master workbook

    I meant A through D. Dang it. ok so I placed a : between all the ranges and I now get a Run-Time Error 1004 at this line:
    LastRow = SrcWkb.Worksheets(2).Cells(Rows.Count, "A:D").End(xlUp).Row

    The sheet names in the master file are Sheet1, Sheet2, Sheet3 but the source file names are custom per tab. I want everything off of tab two Columns A:D. Which parts of the code do you feel is unnecessary? My coding experience is REALLY rusty.

  8. #8
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Copying data from other workbooks and pasting into master workbook

    Please Login or Register  to view this content.
    OR
    Please Login or Register  to view this content.

  9. #9
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Copying data from other workbooks and pasting into master workbook

    I will be off site until tomorrow.

  10. #10
    Registered User
    Join Date
    07-05-2013
    Location
    South Carolina, USA
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Copying data from other workbooks and pasting into master workbook

    Lastrow Should be "D". Here is what I have now and it does run through the sheets but it doesnot paste the values in the master fille.

    Please Login or Register  to view this content.

  11. #11
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Copying data from other workbooks and pasting into master workbook

    This is my guess work on what you are trying to do.
    You should have master book with sheet1 as a destination sheet. Sheet1 has also a header.

    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    07-05-2013
    Location
    South Carolina, USA
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Copying data from other workbooks and pasting into master workbook

    AB33 - Thats exactly what i am looking for. Thank your for your help. You are a life saver!

+ 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] Macro for Copying Cels from All Workbooks to a Single Master Workbook
    By JohnnyJ2013 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-25-2013, 05:51 AM
  2. Conditioned copying/pasting of specific cells from multiple workbooks to master workbook
    By Ziad Homaidan in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-06-2013, 11:39 AM
  3. Replies: 1
    Last Post: 11-21-2012, 11:23 AM
  4. Replies: 1
    Last Post: 07-20-2012, 06:20 PM
  5. Pasting data from MANY workbooks into specific worksheets of a master workbook
    By beemoney19 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-17-2012, 11:30 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