Copy data from active workbook to closed workbook

  • Dear Team,


    I am copying some data from one sheet to another sheet. Test.xlsm is source file and Testdest.xlsm is destination file.


    I had created bellow code for copy my data's.


    The copied data should past next to last updated row.row


    But it is overwriting all the rows from 4th row.


    And serial no also to be updated automatically on column A.


    I attached my files here.


    Can any one help me to solve this issue

  • elsuji

    Changed the title of the thread from “Copy data from active workbook to closed workboob” to “Copy data from active workbook to closed workbook”.
  • Are you simply trying to copy C4, C6, C8, C10, C11 and C19 from the source sheet to the first blank row in the destination sheet and update the serial number in column A?

    You can say "THANK YOU" for help received by clicking the :thumbup: icon in the bottom right corner of the helper's post.
    Practice makes perfect. I am very far from perfect so I'm still practising.

  • Dear Mumps,


    I created code my self and copy paste is working.


    I want add s.no in destination file.


    Kindly help for that

  • Try:

    You can say "THANK YOU" for help received by clicking the :thumbup: icon in the bottom right corner of the helper's post.
    Practice makes perfect. I am very far from perfect so I'm still practising.

  • Do you not want just the values? The code should insert an updated S. No. in column A. Is it not doing that?

    You can say "THANK YOU" for help received by clicking the :thumbup: icon in the bottom right corner of the helper's post.
    Practice makes perfect. I am very far from perfect so I'm still practising.

  • This works for me without errors:

    You can say "THANK YOU" for help received by clicking the :thumbup: icon in the bottom right corner of the helper's post.
    Practice makes perfect. I am very far from perfect so I'm still practising.

  • Dear Mumps,


    I modified the code as per below


    Now it is working with blank sheet also.

  • Dear MUMPS,


    On above code i added two more lines

    Code
    1. On Error Resume Next
    Code
    1. SrcWS.Range("L5") = "OK"


    In this if my destination file is not available, the program is printing only OK in "L5".


    But if my destination file is not available, i want the entire program should stop .


    Kindly tell me how to do this

  • The code checks to see if the file exists. If it does exist, the file is opened and the data is processed. If the file does not exist, the macro exits. You should try to avoid using "on error resume next" if possible because this will hide all errors if they occur. This will make it difficult to debug errors in the code because an error message will not be displayed if an error occurs.

    You can say "THANK YOU" for help received by clicking the :thumbup: icon in the bottom right corner of the helper's post.
    Practice makes perfect. I am very far from perfect so I'm still practising.