+ Reply to Thread
Results 1 to 2 of 2

Simple Macro to Move and Paste

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    03-03-2009
    Location
    UK
    MS-Off Ver
    MS365 Subscription Excel for Mac
    Posts
    1,017

    Simple Macro to Move and Paste

    I have the below code. I want so that if column C row i has the word NAME in it then I want to copy cells D & i + 1 : H & i + 1 and then paste the values into D & i. I then want to delete the entire row i + 1.

    Am I close?

    Dim i As Long, lrow As Long
    
    With Worksheets("PasteHere")
      
        lrow = .Range("A" & .Rows.Count).End(xlUp).Row
        For i = lrow To 3 Step -1
            If .Range("C" & i).Value = "NAME" Then .Range("D" & i + 1 & ":E" & i + 1 & ":F" & i + 1 & ":G" & i + 1 & ":H" & i + 1).Copy
                  
            
            .Range("D" & i).Paste
            .Rows(i + 1).Delete
             
        
        Next i
    
             End With
        
      End Sub

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Simple Macro to Move and Paste

    Very close:

    Dim i As Long, lrow As Long
    
    With Worksheets("PasteHere")
      
        lrow = .Range("A" & .Rows.Count).End(xlUp).Row
        For i = lrow To 3 Step -1
            If .Range("C" & i).Value = "NAME" Then
                .Range("D" & i + 1, "H" & i + 1).Copy .Range("D" & i)
                .Rows(i + 1).Delete
            End If
        Next i
    End With
    If you are happy with my response please click the * in the lower left of my post.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Glitch in excel? Simple table sort, using macro, where pics do not move with cells.
    By hinsdale1 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 04-07-2015, 04:15 AM
  2. My macro needs a couple tweeks- Fairly simple copy and paste macro
    By wiebs2334 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-11-2013, 08:23 PM
  3. Simple macro to move data down one cell in To Do list?
    By mauxhall in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-12-2013, 09:12 AM
  4. Simple VBA code to move, copy, paste, and protect
    By clifton1230 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-13-2013, 11:35 AM
  5. [SOLVED] Simple copy and paste macro- Paste special help needed.
    By hernancrespo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-20-2012, 07:02 AM
  6. simple macro to move around large spreadsheet
    By TheRetroChief in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-06-2010, 10:53 AM
  7. [SOLVED] Need Simple Copy and Insert Row, Move Down Macro
    By spenglef@satx.rr.com in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 02-24-2006, 12:25 PM

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