I've produced a few macros now, by a combination of using recording and help from here, which all work ok, but I want to improve their "efficiency" by reducing the amount of activating and selecting during copying between workbooks. I've put together a simple macro just to try and work out the correct syntax, but am struggling to get it right.
The example has 3 workbooks, code.xls containing the macro, booka.xls containing some source data, and bookb.xls is the workbook to which I want to copy data, all in the same folder:
This works ok.Please Login or Register to view this content.
However I want to get to the point where the macro is in booka.xls, and both booka.xls and bookb.xls are already open, with the correct sheets selected before the macro is run, but I can't get the right syntax for this. Obviously the Set wkbkFrom and Set wkbkTo lines fail because the workbooks are already open. I also think it should also be possible to lose the .Copy in the last two lines and use an =
It's the workbook and worksheet events (I think) that I'm struggling to understand their use.
If someone could give the correct coding, and maybe explain how it's actually working, I might start to understand it a bit more.
Bookmarks