+ Reply to Thread
Results 1 to 4 of 4

Thread: Copy and Paste Macro that pastes to the next open row

  1. #1
    Registered User
    Join Date
    05-13-2010
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2007
    Posts
    7

    Copy and Paste Macro that pastes to the next open row

    Hi there,

    Using the Macro recorde, I create the following basic copy and paste macro:

    Sub moveit()
    '
    ' moveit Macro
    '

    '

    Range("E7:CZ7").Select
    Selection.Copy

    Range("E127").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    End Sub
    Right now, the macros pastes the long line of data to a row 127, but I want it to paste to the next free row (always starting in column E).

    I can't figure out how to do this!
    Last edited by newatmacros; 06-22-2010 at 05:31 PM.

  2. #2
    Forum Guru Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    5,590

    Re: Copy and Paste Macro that pastes to the next open row

    Please wrap your code in code tags, before the moderators get you...

    Forum rules
    3. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # button at the top of the post window. If you are editing an existing post, press Go Advanced to see the # button.

    Cheers

    Then try this
    Sub moveit()
        Dim LastRow As Long
        
        LastRow = Range("E" & Rows.Count).End(xlUp).Row
        
        Range("E7:CZ7").Copy
        Range("E" & LastRow + 1).PasteSpecial Paste:=xlPasteValues, _
                            Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    End Sub

    Hope this helps.

    If you need any further information, please feel free to ask further

    However

    If this takes care of your needs, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED. It helps everybody!
    Also
    If you are satisfied by any members response to your problem please consider using the scales icon top right of thier post to show your appreciation.

  3. #3
    Registered User
    Join Date
    05-13-2010
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Copy and Paste Macro that pastes to the next open row

    Awesome, thanks so much!

    (and thanks for telling me about the forum rule, I didn't know!)

  4. #4
    Forum Guru Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    5,590

    Re: Copy and Paste Macro that pastes to the next open row

    Wrong tags!!!
    Use the # symbol for code, it keeps the BB tidy, and your code easier to recognise

    None-the-less
    Happy to have helped.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.2.0