+ Reply to Thread
Results 1 to 8 of 8

Macro for Copy/Paste from one workbook to another in Excel 2007

  1. #1
    Registered User
    Join Date
    09-19-2012
    Location
    Florida
    MS-Off Ver
    Excel 2007
    Posts
    6

    Macro for Copy/Paste from one workbook to another in Excel 2007

    Hello!

    I am trying to write a macro that copies data from one sheet in a workbook to another sheet in different workbook in Excel 2007. I could really use some guidance on what to do next. Here's the details. Both workbooks will have their own name that will not change over the time the macro is used. ie. Workbook1 and Workbook2 I am looking to copy Column A through Column G every time I run the macro from Workbook1 to Workbook2. The columns will not change. The rows may be longer or shorter each time the workbook1 is updated. Workbook 1 will be updated manually. I was hoping for workbook2 I could run a macro. I tried the record macro feature in excel and it works fine for the first time. But, the second time it does not paste the updated data in workbook1 to workbook2. It's like it references the data that is already on the clipboard not the new data in the workbook. Does anyone have code to make this work or a reason why this is not working? I would really appreciate it.

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Macro for Copy/Paste from one workbook to another in Excel 2007

    Hi Blackjack12

    After you've pasted your data add this line of code
    Please Login or Register  to view this content.
    Better yet...post your code

    Better yet...post your workbook.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Forum Contributor
    Join Date
    08-01-2012
    Location
    Tampa
    MS-Off Ver
    Excel 2010
    Posts
    121

    Re: Macro for Copy/Paste from one workbook to another in Excel 2007

    @Blackjack

    It doesnt work the second time most likely because you need to give it proper references. Recording will give you the layout, but then you will need to go refine the code to make it dynamic if need be, such as if data changes, you need to tell it to go to the last row and copy over from there, each time. You have not specified whether you want to fully replace data in workbook2 each time you run the macro, or create a updated list, adding everything from workbook1 into the next available space in workbook2. Post the code you are working with as well.
    Last edited by Cutter; 09-20-2012 at 11:53 AM. Reason: Removed whole post quote

  4. #4
    Registered User
    Join Date
    09-19-2012
    Location
    Florida
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Macro for Copy/Paste from one workbook to another in Excel 2007

    Thank you Jaslake for your code. I am going to try this first thing in the morning when I will have the file. If it doesn't work I'll send my code over along with an example of the workbook. Jayinth813, that makes complete sense. I am looking to fully replace the data in workbook2. I'll see what happens in the morning. Thank you both!

  5. #5
    Registered User
    Join Date
    09-19-2012
    Location
    Florida
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Macro for Copy/Paste from one workbook to another in Excel 2007

    Thank you Jaslake for your code! It seems to work just fine. It looks like it is clearing out the memory and pasting the newest data available. Thanks again!

  6. #6
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Macro for Copy/Paste from one workbook to another in Excel 2007

    Hi Blackjack12

    You're welcome. If that satisfies your requirement please mark your Thread as SOLVED.

  7. #7
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Macro for Copy/Paste from one workbook to another in Excel 2007

    @ Blackjack12

    Welcome to the forum.

    Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED. I'll do that for you now but please keep in mind for your future threads that Rule #9 requires you to do that yourself. If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
    Thanks.

    Also, as a new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

  8. #8
    Registered User
    Join Date
    09-19-2012
    Location
    Florida
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Macro for Copy/Paste from one workbook to another in Excel 2007

    Ok Cutter Thank you. I was just logging in to mark my 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)

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