+ Reply to Thread
Results 1 to 10 of 10

Copy and Paste from Workbook to another Workbook - VBA

  1. #1
    Forum Contributor
    Join Date
    02-20-2014
    Location
    Ireland
    MS-Off Ver
    Excel 2013
    Posts
    108

    Copy and Paste from Workbook to another Workbook - VBA

    Hi All,

    I think this should be simple for any excel ninjas on here, I am relatively new to VBA, and so am no good at starting code from scratch.

    I want to copy specific cells from a workbook called Master.xlsx and paste them into the next available row in another workbook called Time.xlsx

    The cells from the first workbook will be from "Sheet 4" B36:K36 and to be pasted into the next available row in the Time.xlsx workbook

    Any help be great

    Regards

    Simon

  2. #2
    Valued Forum Contributor
    Join Date
    11-02-2012
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    564

    Re: Copy and Paste from Workbook to another Workbook - VBA

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    02-20-2014
    Location
    Ireland
    MS-Off Ver
    Excel 2013
    Posts
    108

    Re: Copy and Paste from Workbook to another Workbook - VBA

    Thanks for the quick reply, I wasn't very clear even with myself there as to what i wanted. The document to be copied from will always be the active workbook and jus so happens to be called Master.xlsx.

    These documents come in, in vast quantities, they are then viewed and logged by hand. I would like a code so once viewed a button or hot key can be pressed to copy and paste the specific cells to a document set in a specific location.

    I tried playing around with your code but keep receiving an error "subscript out of range"

    I also notice the paste special function in your code, but plain old text is all i am copying

  4. #4
    Forum Contributor pareshj's Avatar
    Join Date
    05-20-2014
    Location
    MUMBAI
    MS-Off Ver
    2007 & 2010
    Posts
    447

    Re: Copy and Paste from Workbook to another Workbook - VBA

    Hi Simon,

    Check this code, hope this will help you :

    Please Login or Register  to view this content.

    Regards,
    Paresh J
    Click on "* Add Reputation" as a way to say thanks

  5. #5
    Valued Forum Contributor
    Join Date
    11-02-2012
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    564

    Re: Copy and Paste from Workbook to another Workbook - VBA

    The document to be copied from will always be the active workbook and jus so happens to be called Master.xlsx.
    Replace Workbooks(Master.xlsx) with ActiveWorkbook

    I would like a code so once viewed a button or hot key can be pressed to copy and paste the specific cells to a document set in a specific location.
    Assign this macro to a button (Insert a shape / button / picutre from Insert tab. Right click on the shape and click Assign Macro, select this macro name) or assign a shortcut key to this macro. (View > Macros > Options)
    I tried playing around with your code but keep receiving an error "subscript out of range"
    That may be because you are playing with a file whose name is not Master.xlsx or it doesn't have a sheet named Sheet4. To be pasted book should be named Time.xlsx.... This is all hard coded there based on the information you gave in the post. You might want to change it as per your needs.
    I also notice the paste special function in your code, but plain old text is all i am copying
    Doesn't matter. It still works.

  6. #6
    Forum Contributor
    Join Date
    02-20-2014
    Location
    Ireland
    MS-Off Ver
    Excel 2013
    Posts
    108

    Re: Copy and Paste from Workbook to another Workbook - VBA

    Apologies haripopuri, as i had stated at the start of this thread I am new enough to VBA, the code you supplied I found difficult to understand, because I am new.

    Thank you pareshj for your code, this is something I am more familiar with however I'm not sure how to go about changing the "InputPath" to be the activeworkbook. I have been trying different things but to no avail, any more help be really appreciated.

    Regards
    Simon

  7. #7
    Forum Contributor pareshj's Avatar
    Join Date
    05-20-2014
    Location
    MUMBAI
    MS-Off Ver
    2007 & 2010
    Posts
    447

    Re: Copy and Paste from Workbook to another Workbook - VBA

    Hi Simon,

    Just enter the Inputpath as where your Master.xlsx file is located.
    and OutputPath as where you have your Time.xlsx


    Regards,
    Paresh J

  8. #8
    Forum Contributor
    Join Date
    02-20-2014
    Location
    Ireland
    MS-Off Ver
    Excel 2013
    Posts
    108

    Re: Copy and Paste from Workbook to another Workbook - VBA

    I had overlooked a few things in my original post

    The document sent out to fellow employees is called master.xlsx however when it is sent back to us in the office it may have been renamed for whatever reason. Each workbook received is opened to be reviewed, and so to have the code run from the already open workbook would avoid any issues with renamed documents, the sheets within the workbook will always remain the same.

    I had filled in the locations of my documents into your code, but this causes the excel document to close to reopen. If this was avoidable it would be great

    Thanks again

  9. #9
    Forum Contributor
    Join Date
    02-20-2014
    Location
    Ireland
    MS-Off Ver
    Excel 2013
    Posts
    108

    Re: Copy and Paste from Workbook to another Workbook - VBA

    Just thought I will post my finished code for all to see, thanks for everybodies help on this topic

    Please Login or Register  to view this content.

  10. #10
    Forum Contributor pareshj's Avatar
    Join Date
    05-20-2014
    Location
    MUMBAI
    MS-Off Ver
    2007 & 2010
    Posts
    447

    Re: Copy and Paste from Workbook to another Workbook - VBA

    Hi,


    Glad to help you.


    Regards,
    Paresh J

+ 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 to find data in source workbook and copy paste to target workbook
    By D.Lovell in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 04-23-2014, 06:21 AM
  2. [SOLVED] Copy Specific Cells Across all worksheets in a Workbook and Paste Into single New Workbook
    By thunt13 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-14-2013, 10:43 AM
  3. Simple Open Workbook, Copy Sheet, Paste In New Workbook Question
    By alulla in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-19-2013, 02:10 PM
  4. Replies: 2
    Last Post: 09-11-2012, 09:42 AM
  5. Simple task: Open a workbook, copy a range, paste into another workbook
    By fbonetti in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-21-2011, 01:12 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