+ Reply to Thread
Results 1 to 6 of 6

Copy selected data from one workbook to another

  1. #1
    Registered User
    Join Date
    06-07-2014
    Posts
    2

    Copy selected data from one workbook to another

    Hi All.
    I'm a bit new here & also new with VB. I have 2 workbooks. In WB 1 some data are there. Now I need to copy those data to WB 2. But not all of them. I've attached both the files here. In srcsht there are 9 columns. In destsht there are only 5. Plus based on column 4 in srcsht i.e. Region, i need to copy the data for only East & not the rest, which is there at destsht in column 2.
    Another thing is as i enter more rows in srcsht, the same should be increased in destsht too.

    Can anyone help me how to do this...

    Thanks in advance.
    Soumya
    Attached Files Attached Files

  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: Copy selected data from one workbook to another

    Hi sjm.sonu82

    Welcome to the Forum!!!

    Can I use a Column in srcsht Sheet1 to mark the Records as having been processed so they're not processed again?
    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 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: Copy selected data from one workbook to another

    Hi sjm.sonu82

    I've taken the liberty of using Column K to mark records as processed.

    Place both these Files in the same Folder. Open srcsht.xlsm...CTRL + x will fire the Code. If destsht.xlsx is not open the Code will open it.

    Let me know of issues.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Re: Copy selected data from one workbook to another


    Hi !

    When destination columns titles are equal to source ones, easy way is using Excel function Advanced Filter …
    Little demonstration with source and destination workbooks already opened :

    PHP Code: 
    Sub Demo()
        
    With Workbooks("destsht.xlsx").Worksheets(1)
            
    Application.ScreenUpdating False
                        
    .[K1:K2].Value = [{"Region";"East"}]
            
    Workbooks("srcsht.xlsx").Worksheets(1).Cells(1).CurrentRegion.AdvancedFilter xlFilterCopy, .[K1:K2], .[A1:E1]
                        .[
    K1:K2].Clear
        End With
    End Sub 
    Do you like it ? So thanks to click on bottom left star icon « Add Reputation » !

  5. #5
    Registered User
    Join Date
    06-07-2014
    Posts
    2

    Re: Copy selected data from one workbook to another

    Hi Jaslake...awesome...it worked. Thanks a lot guruji...
    Hi Marc. Thanks for your reply too...although i didn't try that but still thanks for quick response

  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: Copy selected data from one workbook to another

    You're welcome...glad I could help. Thanks for the Rep.

+ 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. Replies: 1
    Last Post: 03-15-2014, 05:44 AM
  2. Copy selected row from one workbook to another
    By M1234 in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 07-23-2013, 12:56 PM
  3. Replies: 2
    Last Post: 05-01-2013, 05:37 AM
  4. [SOLVED] Copy selected range of data and paste in new open workbook
    By coach.32 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-26-2013, 03:41 AM
  5. [SOLVED] Browse a File, Copy Selected data from it and paste it to other workbook (Active)
    By FCarv in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-24-2012, 09:46 AM
  6. [SOLVED] copy selected data from a workbook to another spreadsheet each time I run a template
    By mickyh in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-05-2012, 07:18 PM
  7. copy data from selected cells , in selected row and paste it to ms word table ?
    By aaashaaa in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-06-2010, 03:25 PM
  8. Copy selected data to Workbook on Desktop
    By hutch@edge.net in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-14-2009, 11:17 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