PDA

View Full Version : Copy & Pasting in VBA



hockeyfan
11-18-2009, 10:23 AM
What is the most efficient way to copy and paste in VBA. For some reason I always have to select the cell that I want to paste into. Not only that but I seem to have to do:

Range("A1").Select
activesheet.selection.paste

Why is that? Whats the point, is there any way to cut,copy, and paste without using active cells?

p45cal
11-18-2009, 11:49 AM
Range("C4:D6").Cut Range("A1")
or
Range("C4:D6").Cut Destimation:=Range("A1")
If they're on different worksheets, specify them. You can substitute Copy for Cut.

arkusM
11-19-2009, 07:23 AM
What is the most efficient way to copy and paste in VBA. For some reason I always have to select the cell that I want to paste into. Not only that but I seem to have to do:

Range("A1").Select
activesheet.selection.paste

Why is that? Whats the point, is there any way to cut,copy, and paste without using active cells?

A Simple "Copy Paste"

Range("B2").value = Range("A1")

EDIT:
I see that I was a day late and a dollar short. LOL

CDTech
04-27-2010, 02:03 PM
Sorry to dredge this thread back up but it fits my situation.

I'm no stranger to VB and VBA but I'm having a devil of a time trying to figure out how to copy and paste in Excel VBA. I have the Que book and while it's a decent reference it doesn't go into the various methods one can use. I never liked online help as it's generally too terse -- unless you already know how to use VBA it's nearly useless.

I want to copy a row with a variable number of cells and paste it to another sheet. In Excel, it's easy-peasy. Select the range, copy to the clipboard, select the new sheet and upper-left cell then paste.

Pasting to the activecell is clumsy for what I want to do and I just can't seem to grasp how to use range objects. Rather than try and fix my problem here, I was hoping someone could point to reading material that explores the various methods to copy and paste in Excel using VBA. Google hasn't been a lot of help...yet.

Thanks