Copy Data

  • Dear forum


    I'm in dire need of a simple code to ease my repetitive work


    I open 2 files : A & B. Once I finish copying data from B into A. I close B and open C and so on. That means I always work with file A (active)


    File B, C or D and so on has 3 worksheets with identical names. The filename of B, C and so on also has some common word


    I'd like to copy data into sheet1 of file A, always same range : B2:B100 , afterwards I would copy-paste each result from sheet1 to another sheet of file A and delete the data in sheet1. So sheet1 of file A is always active and show the result each time the macro was run as follows.



    Cell b2 of file A = cell c1 of sheet 1 of file B
    Cell b3 of file A = cell d1 sheet 1 of file B + cell e1 of sheet 2 of file B


    I'd be thankful if someone could write me the code.


    Best regards

  • Re: Copy Data


    You best turn on the macrorecorder the next time you do all the copying. Don't forget to store this macro as a personal macro, this gives you the opportunity to jump from filie to file.

  • Re: Copy Data


    Could some one please tell me what's wrong with this code , especially the value lines


    Thank you

  • Re: Copy Data


    thank you for your reply, it gives me hope!


    the sentence

    Code
    ActiveSheet.Range("e12") = WB.WS1.Range("H56").Value


    was highlighted and the code was blocked.
    So I think the forluala was nor correct

  • Re: Copy Data


    WS1 & WS2 belong to the same workbook (ISO PHL May06 Local Cost report)which is open


    Activesheet belong to another workbook, where the code was run, data will be imported from workbook ISO Costs report into the activesheet


    Thank you

  • Re: Copy Data


    Quote from royUK

    Please do't keep adding posts, edit them instead. You are creating work for the site administrators.


    To be fair, Roy, since I had deleted them, I don't think the OP could edit them.

  • Re: Copy Data


    Quote from ByTheCringe2

    To be fair, Roy, since I had deleted them, I don't think the OP could edit them.


    I thoght you had deleted after new ones were added, sorry VON

  • Re: Copy Data


    Unfortunately it did not work. The files were heavier than permitted so I can not attach it here
    If I replace the right hand side formula with a number. The cose works. So I'd think there is problem with the codification of WB, WS.


    Thank you

  • Re: Copy Data


    If I copy data within the same workbook, my above mentionned code works well. But because I need to copy data to another workbook (active sheet), there must be somthing wrong with the way I codify the soure workbook "WB" which is open but not active while I do the copying.
    Thank you for your advice

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!