Consulting

Results 1 to 4 of 4

Thread: Copy & Pasting in VBA

  1. #1

    Copy & Pasting in VBA

    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?

  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,874
    Range("C46").Cut Range("A1")
    or
    Range("C46").Cut Destimation:=Range("A1")
    If they're on different worksheets, specify them. You can substitute Copy for Cut.
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  3. #3
    VBAX Regular arkusM's Avatar
    Joined
    May 2007
    Location
    Calgary
    Posts
    52
    Location
    Quote Originally Posted by hockeyfan
    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
    Excel 2003, WinXP

  4. #4
    VBAX Regular
    Joined
    Feb 2008
    Posts
    7
    Location
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •