Search code examples
vbaexcelcopycopy-paste

VBA Copy and Paste to Row +1 below


I'm trying to write some code that will copy and paste data in cells A3:A6 to A8:A11 and then when run again it will paste it the row +1 beneath, so the next time it's run the data in A8:A11 will be copy and pasted into A13:A16 and the next time after that it's run it will paste the data in A13:16 to A18:21 and so on.

The below is what I've tried to come up with but I might be quite a way off, any guidance will be appreciated:

Sub RollFile()

Dim UsdRows As Long

UsdRows = Cells(Rows.Count, 3).End(xlToUp).Row
With Range(Cells(1, UsdRows), Cells(UsdRows, 1))
  .Copy .Offset(, 1)
  .Value = .Value
  .Offset(-1, 1)(1).Select
End With

End Sub

Many thanks


Solution

  • you could try this

    Sub RollFile()
    
        With Cells(Rows.Count, 1).End(xlUp) ' reference column A last not empty cell
            With Range(.End(xlUp), .Cells) ' reference the range from referenced cell up to last adjacent one
                .Offset(.Rows.Count + 1).Value = .Value ' copy referenced range values to a range two row below its end
            End With
        End With
    
    End Sub