+ Reply to Thread
Results 1 to 9 of 9

macro for copy data Workbook1 and paste to Workbook2

  1. #1
    Forum Contributor
    Join Date
    01-29-2012
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    434

    macro for copy data Workbook1 and paste to Workbook2

    Sir
    i m looking a macro for my project..

    Where 2 excel workbook (Ex, workbook1 & workbook2 )..

    We want to copy data from workbook 2 to workbook 1

    in workkbook1 Sheet name (RD-1)
    in workkbook2 Sheet name (RD-2)

    Workbook1 (Sheet RD-1)

    A B C D
    item1 10 12 120
    item2 5 8 40
    item3 15 6 90



    Workbook2 (Sheet RD-2)
    A B C D
    item1 10 12 120
    item2 5 8 40
    item3 15 6 90
    item4 20 10 200
    item5 170 5 850
    item6 15 5 75



    After Run Macro Resulted Workbook1 (Sheet RD-1)
    A B C D
    item1 10 12 120
    item2 5 8 40
    item3 15 6 90
    item4 20 10 200
    item5 170 5 850
    item6 15 5 75



    Actually if workbook2 item already add in workboko1 then then record not copy... in examle only copy item 4,5,6 coz itme 1,2,3 already in workbook1


    hope u friends & forum guru help me solve this problem..

    Thanks in advance

    Santosh

  2. #2
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: macro for copy data Workbook1 and paste to Workbook2

    Hi Santosh,
    I have two options for you
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    both files ('Book1' and 'Book2') must be open

  3. #3
    Forum Contributor
    Join Date
    01-29-2012
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    434

    Re: macro for copy data Workbook1 and paste to Workbook2

    Thank u so much sir for help me but.. after running this macro (1st one) a msg box display in vba code subscript out of range whenever both file book1 & book both open

    i m copying ur code in book1 is it ok?

  4. #4
    Forum Contributor
    Join Date
    01-29-2012
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    434

    Re: macro for copy data Workbook1 and paste to Workbook2

    Sorry Nilim sir it's works.. actually after saving both file when we try that run..

    Thank you so much for above macro thanks

  5. #5
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: macro for copy data Workbook1 and paste to Workbook2

    Quote Originally Posted by santosh226001 View Post
    i m copying ur code in book1 is it ok?
    yeah, right
    to take into account all possible errors in the files, one need to write a branched error handler in the code. This will increase the code multiple times. Therefore it will be better if you attach the sample files Book1 and Book2
    Edited
    Oh, I am writing in English for too long

  6. #6
    Forum Contributor
    Join Date
    01-29-2012
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    434

    Re: macro for copy data Workbook1 and paste to Workbook2

    Nilim sir is it possible if we not define book1 name & macro automatically read workbook name which one we run macro..??? coz some time we change workbook name in saving time so again change name in macro...only book1 name condtion.. pls

  7. #7
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: macro for copy data Workbook1 and paste to Workbook2

    try it
    Please Login or Register  to view this content.
    In this case must be opened only two of your books

  8. #8
    Forum Contributor
    Join Date
    01-29-2012
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    434

    Re: macro for copy data Workbook1 and paste to Workbook2

    ok sir but if we want to compare insted of Colum A value ..... we compare other column like B or C then where we change.. pls suggest me..also thanks

  9. #9
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: macro for copy data Workbook1 and paste to Workbook2

    Quote Originally Posted by santosh226001 View Post
    ...we compare other column like B
    Please Login or Register  to view this content.
    Quote Originally Posted by santosh226001 View Post
    ...we compare other column like C
    Please Login or Register  to view this content.

+ 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