+ Reply to Thread
Results 1 to 4 of 4

Copy and Paste Macro

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    12-13-2007
    Posts
    138

    Copy and Paste Macro

    Hi everyone. I need some help on a copy and paste macro. Basically I need the macro to perform a few actions:

    1. In whatever cell is selected when the macro is run, enter a new row.

    2. Copy the information from the row directly above the new row and paste (values, formulas, formats, etc) into the new row.

    3. Return to column P in the new row, i.e if the new row is row 11, then return to P11, for row 12 return to P12, etc.

    I have tried recording the macro but because it is hard coded to specific rows, its not working.

    I have attached a sample copy of the sheet (had to zip due to the size of the file). Any help will be greatly appreciated. Thanks in advance.
    Last edited by FM1; 01-07-2009 at 11:46 AM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464
    Hi,

    Macros code as follows to achieve all three:

    ActiveCell.Offset(1, 0).EntireRow.Insert
    ActiveCell.EntireRow.Copy Destination:=Range("A" & ActiveCell.Row + 1)
    Range("P" & ActiveCell.Row + 1).Select
    HTH

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689
    Sub x()
        With Selection
            .EntireRow.Copy
            .Offset(1).EntireRow.Insert
            Application.CutCopyMode = False
            Cells(.Row + 1, "P").Select
        End With
    End Sub
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Forum Contributor
    Join Date
    12-13-2007
    Posts
    138
    Quote Originally Posted by Richard Buttrey View Post
    Hi,

    Macros code as follows to achieve all three:

    ActiveCell.Offset(1, 0).EntireRow.Insert
    ActiveCell.EntireRow.Copy Destination:=Range("A" & ActiveCell.Row + 1)
    Range("P" & ActiveCell.Row + 1).Select
    HTH
    Quote Originally Posted by shg View Post
    Sub x()
        With Selection
            .EntireRow.Copy
            .Offset(1).EntireRow.Insert
            Application.CutCopyMode = False
            Cells(.Row + 1, "P").Select
        End With
    End Sub
    Hi guys. Both macros worked perfectly (just operate in different ways). Thanks very much for your help.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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.6.0 RC 1