Copy cells between workbooks

前端 未结 3 1819
终归单人心
终归单人心 2020-12-18 01:23

Could someone please help me with some VBA code.

I am trying to copy 2 ranges of cells between workbooks (both workbooks should be created beforehand as i don\'t wan

3条回答
  •  臣服心动
    2020-12-18 02:14

    You can use special cells like Jonsca has suggested. However, I usually just loop through the cells. I find it gives me more control over what exactly I am copying. There is a very small effect on performance. However, I feel that in the office place, making sure the data is accurate and complete is the priority. I wrote a response to a question similar to this one that can be found here:

    • StackOverflow - Copying Cells in VBA for Beginners

    There is also a small demonstration by iDevelop on how to use special cells for the same purpose. I think that it will help you. Good luck!

    Update

    In response to...

    good start but it doesn't copy anything after the first blank cell – trunks Jun 9 '11 at 5:08

    I just wanted to add that the tutorial in the link above will address the issue brought up in your comment. Instead of using the .End(xlDown) method, loop through the cells until you reach the last row, which you retrieve using .UsedRange.Rows.Count.

提交回复
热议问题