PDA

View Full Version : copy range from different sheets



alienscript
06-26-2008, 06:51 PM
Hi the expert,

I hope to receive some help on copy using VB code. I'm using Excel2003.

I tried to copy only range B and E only from all sheets and append individually to Sheet("check"). That is, only copy column "Part Number" and col "JUne-08". However, it copied range B:G. How to copy only col B and E?

Thanks.

JimmyTheHand
06-26-2008, 11:06 PM
One line of code needs to be modified. Replace
sh.Range(sh.Range("B2" & ":B" & lastrow), sh.Range("E2" & ":J" & lastrow)).Copy with
sh.Range("B2:B" & lastrow & ",E2:E" & lastrow).Copy

Jimmy

alienscript
06-26-2008, 11:47 PM
I gotta be more careful with use of & operator. Thanks Jimmy:yes

JimmyTheHand
06-27-2008, 04:02 AM
I gotta be more careful with use of & operator.
You used more & operators than necessary, but still they were OK, the problem was elsewhere.
It's more like you need to make sure you understand the difference between
Range("A2:B2", "F4:H8").Select and
Range("A2:B2, F4:H8").Select
Jimmy