Macro that copy and pastes last used row under last used row

paytoplay

New Member
Joined
Nov 1, 2017
Messages
1
This is my macro so far. It copies and pastes the last used row under the last used row. I just want it to copy and paste the last row of A-I, but messes up when I try to input it.

Dim lRow As Long

ThisWorkbook.Activate
lRow = Worksheets("Sheet1").Cells(Worksheets("Sheet1").Rows.Count, 1).End(xlUp).Row
Range("A" & lRow).Copy
lRow = lRow + 1
Range("A" & lRow).PasteSpecial
Application.CutCopyMode = False
End Sub



Thanks
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Here are three similar examples to copy the last row to the next empty row.

I used Sheet1, you will change to your sheet name. A couple Msgbox lines for added info, uncomment lines to see Msgbox's

Howard

Code:
Option Explicit


Sub Copy_Last_Row_1()

  Sheets("Sheet1").Range("A1:A" & Cells(Rows.Count, "A").End(xlUp).Row).EntireRow.Copy
  Range("A" & Rows.Count).End(xlUp)(2).PasteSpecial Paste:=xlPasteValues

Application.CutCopyMode = False
End Sub



Sub Copy_Last_Row_2()

Dim sh As Worksheet, rng As Range, lRow As Long, LCol As Long
Set sh = Sheets("Sheet1")

LCol = sh.Cells.Find("*", , xlFormulas, xlPart, xlByColumns, xlPrevious).Column
lRow = sh.Cells.Find("*", , xlFormulas, xlPart, xlByColumns, xlPrevious).Row

'MsgBox "Last row is " & lRow & " " & "Last column is " & LCol

sh.Range(sh.Cells(lRow, 1), sh.Cells(lRow, LCol)).Copy
Range("A" & Rows.Count).End(xlUp)(2).PasteSpecial Paste:=xlPasteValues

Application.CutCopyMode = False
End Sub



Sub Copy_Last_Row_3()

Dim sh As Worksheet
Dim lastColumn As Integer
Dim lastRow As Long
Set sh = Sheets("Sheet1")

 lastRow = ActiveSheet.Range("A1").End(xlDown).Row
 lastColumn = ActiveSheet.Range("A" & lastRow).End(xlToRight).Column
 
'MsgBox lastRow & " " & lastColumn

sh.Range(sh.Cells(lastRow, 1), sh.Cells(lastRow, lastColumn)).Copy
Range("A" & Rows.Count).End(xlUp)(2).PasteSpecial Paste:=xlPasteValues

 Application.CutCopyMode = False
End Sub
 
Upvote 0
Try this:
Code:
Sub Copy_Lastrow()
Rows(Cells(Rows.Count, "A").End(xlUp).Row).Copy Rows(Cells(Rows.Count, "A").End(xlUp).Row + 1)
End Sub
 
Upvote 0
If you only want to copy values you could use this:
Code:
Sub Copy_Lastrow()
Rows(Cells(Rows.Count, "A").End(xlUp).Row).Resize(2).Value = Rows(Cells(Rows.Count, "A").End(xlUp).Row).Value
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,943
Messages
6,181,921
Members
453,071
Latest member
Gizmo2024

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top