+ Reply to Thread
Results 1 to 18 of 18

Copy one workbook to Another WorkBook

  1. #1
    Registered User
    Join Date
    05-01-2020
    Location
    CHENNAI
    MS-Off Ver
    EXCEL 2010
    Posts
    88

    Post Copy one workbook to Another WorkBook

    I have two open workbooks. I need to select data from one workbook (active worksheet) once i selected, that need to be pasted in another workbook opened, the parent workbook is having multiple sheet so its should be pasted on active worksheet. Before pasting on the parent workbook the active worksheet all rows to be deleted. Doing this manually taking more time. if some one help me for VBA code . it will be helpful.

  2. #2
    Valued Forum Contributor
    Join Date
    11-04-2018
    Location
    Denpasar
    MS-Off Ver
    Excel 2010
    Posts
    576

    Re: Copy one workbook to Another WorkBook

    Sorry, I'm not helping here.
    I just want to understand your situation.

    You have two workbooks.
    1. Workbook-A ---> this is what you call "parent" workbook
    2. Workbook-B

    Workbook-A has many sheets, anyway, the current condition is Sheet1 ---> this is what you call the active sheet of the parent workbook.

    Now in Workbook-B you select a range of data.
    The automation you want is the code to copy your selected range in workbook-B (whatever active sheet name)
    then paste it to your last blank row of data in the active sheet (Sheet1 in this example) of the parent workbook (workbook-A)
    after that it delete the rows of your selected range in workbook-B.

    Is that what you mean ?

    or this one :
    Now in Workbook-B you select a range of data.
    The automation you want is the code to delete all the cells in the active sheet (Sheet1 in this example) of the parent workbook (workbook-A)
    then copy your selected range in workbook-B (whatever active sheet name)
    then paste it to the first row of the active sheet (Sheet1 in this example) of the parent workbook (workbook-A)
    Last edited by karmapala; 05-07-2020 at 05:43 AM.

  3. #3
    Registered User
    Join Date
    05-01-2020
    Location
    CHENNAI
    MS-Off Ver
    EXCEL 2010
    Posts
    88

    Re: Copy one workbook to Another WorkBook

    I want to copy Workbook B Active Sheet(whatever active sheet name) entire data

    Then i need to paste in workbook A Active Sheet(whatever active sheet name) entire data.

  4. #4
    Valued Forum Contributor
    Join Date
    11-04-2018
    Location
    Denpasar
    MS-Off Ver
    Excel 2010
    Posts
    576

    Re: Copy one workbook to Another WorkBook

    Quote Originally Posted by SARAN89 View Post
    I want to copy Workbook B Active Sheet(whatever active sheet name) entire data

    Then i need to paste in workbook A Active Sheet(whatever active sheet name) entire data.
    And in what workbook that you want to delete the whole cells of the active sheet ?

  5. #5
    Forum Contributor
    Join Date
    12-18-2019
    Location
    chennai
    MS-Off Ver
    excel 2010
    Posts
    100

    Re: Copy one workbook to Another WorkBook

    Active Sheet of Workbook A

  6. #6
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    3,248

    Re: Copy one workbook to Another WorkBook

    You cannot have two active sheets in two different workbooks.
    The only activesheet is the visible sheet in front of you on the desktop.
    So you either have to give the name of the sheet you want to copy from or make the 2nd workbook active and whatever sheet shows up on the desktop is the active sheet of that workbook.
    That would be something like
    Please Login or Register  to view this content.
    Written in the raw so don't take it as gospel until tried.

  7. #7
    Registered User
    Join Date
    05-01-2020
    Location
    CHENNAI
    MS-Off Ver
    EXCEL 2010
    Posts
    88

    Re: Copy one workbook to Another WorkBook

    Hi

    I will copy manually from Work Book "B", then i will go to Work book A and execute the code. It will work?. The code is like deleting all rows of active sheet of workbook "A" and then to be pasted, what i am copied from Workbook "B"

    Kindly help me VBA code for this.

  8. #8
    Valued Forum Contributor
    Join Date
    11-04-2018
    Location
    Denpasar
    MS-Off Ver
    Excel 2010
    Posts
    576

    Re: Copy one workbook to Another WorkBook

    Maybe something like this :
    Please Login or Register  to view this content.
    1. This code has to be in the wbA (Parent.xlsm).
    2. Before running the code, you have to be sure that the active sheet in wbB is the one that you want to copy
    3. then back to wbA to run the code
    Last edited by karmapala; 05-08-2020 at 02:40 AM.

  9. #9
    Registered User
    Join Date
    05-01-2020
    Location
    CHENNAI
    MS-Off Ver
    EXCEL 2010
    Posts
    88

    Re: Copy one workbook to Another WorkBook

    Hi
    Workbook B name is not specific, like WB-B

    every time it will change. Can you modify the code to use any open workbook.
    Last edited by SARAN89; 05-20-2020 at 11:50 AM.

  10. #10
    Valued Forum Contributor
    Join Date
    11-04-2018
    Location
    Denpasar
    MS-Off Ver
    Excel 2010
    Posts
    576

    Re: Copy one workbook to Another WorkBook

    Quote Originally Posted by SARAN89 View Post
    Hi
    Workbook B name is not specific
    Maybe like this :

    Please Login or Register  to view this content.

    It MUST only two workbooks open.
    If it's only one workbook open, the code will fail.
    If it's more then one workbook open, the code will fail.
    If the active sheet in wbB is not the sheet which is going to be copied to wbA,
    you will get a result which is not expected.

    Not tested.

  11. #11
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    3,248

    Re: Copy one workbook to Another WorkBook

    You can have as many workbooks open as you want.
    It's your choice

    See attached
    First select a workbook from the list and than select a sheet from the other list.
    Site security would not let me post some additional info.
    It is in the attached notepad file
    Attached Files Attached Files
    Last edited by jolivanes; 05-20-2020 at 03:08 PM.

  12. #12
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    3,248

    Re: Copy one workbook to Another WorkBook

    Re:
    I want to copy Workbook B Active Sheet(whatever active sheet name) entire data
    Then i need to paste in workbook A Active Sheet(whatever active sheet name) entire data.

    Please Login or Register  to view this content.
    You might have to change this
    Please Login or Register  to view this content.
    to this
    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    05-01-2020
    Location
    CHENNAI
    MS-Off Ver
    EXCEL 2010
    Posts
    88

    Re: Copy one workbook to Another WorkBook

    Hi jolivanes

    Excellent your code is working fine. one small change is required. Currently its pasting the data on "A1" . but i required as its in source workbook. like if its in B9 then it should paste in B9 of target workbook.

  14. #14
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    3,248

    Re: Copy one workbook to Another WorkBook

    Please Login or Register  to view this content.

  15. #15
    Registered User
    Join Date
    05-01-2020
    Location
    CHENNAI
    MS-Off Ver
    EXCEL 2010
    Posts
    88

    Re: Copy one workbook to Another WorkBook

    Hi jolivanes thank you so much. Its pasting as required. but formatting is showing different. I need to include the below lines but not sure where i need add i tried but getting errors

    Please Login or Register  to view this content.

  16. #16
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    3,248

    Re: Copy one workbook to Another WorkBook

    Change this
    Please Login or Register  to view this content.
    to this
    Please Login or Register  to view this content.
    Next time, before you post, think things through on what you need so we dont have a change or addition every suggestion.
    Last edited by jolivanes; 05-21-2020 at 02:19 AM. Reason: code tags

  17. #17
    Registered User
    Join Date
    05-01-2020
    Location
    CHENNAI
    MS-Off Ver
    EXCEL 2010
    Posts
    88

    Re: Copy one workbook to Another WorkBook

    Hi jolivanes

    I thought it will paste same as source hence not informed early. The addition line is working fine. thanks for your help.

  18. #18
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    3,248

    Re: Copy one workbook to Another WorkBook

    No worries
    Good Luck

+ 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] Copy columns to new workbook with matched headers, then save new workbook as a text file.
    By haitran in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-17-2017, 05:53 PM
  2. Replies: 3
    Last Post: 12-07-2017, 05:14 PM
  3. [SOLVED] VBA Macro pull a certain cell in closed workbook and copy/paste into current workbook
    By Hoover5896 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-08-2017, 01:36 AM
  4. Assign name to Workbook, Copy range from one workbook to another workbook
    By jakopak in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-18-2015, 03:40 AM
  5. Copy data one workbook to another workbook without opening workbook
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-04-2014, 11:28 AM
  6. [SOLVED] Copy Values From Each Workbook in Folder to a Single Sheet in New Workbook +Workbook names
    By Arsham24 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-21-2012, 07:42 PM
  7. Replies: 1
    Last Post: 04-01-2006, 03:50 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