Copy last row of data and paste into specified range

dgray21781

New Member
Joined
Aug 29, 2015
Messages
7
I am trying to copy the last row of entered data from the range B8:O34 and paste it into the range B7:O7. When I run this macro I would like it to overwrite the data in A7:O7 and not continue listing the data in consecutive rows.

Sub CopyLastRow()
Dim lRw As Long
With ActiveSheet
lRw = Cells.Find("*", .Range("A" & Rows.Count), , , xlByRows, xlPrevious).Row
.Rows(lRw).Copy
End With
With Sheets("Sheet1")
lRw = Cells.Find("*", .Range("A" & Rows.Count), , , xlByRows, xlPrevious).Row
.Rows(lRw + 1).PasteSpecial Paste:=xlPasteValues
End With
End Sub

I have tried the above code to see if I can get the last row copying and work from there. This copies the very last line which is effectively a footer for the sheet and places it in row 40 on the destination sheet. I need it in a specified row.
 
Got it

Sub Button1_Click()
Dim sh As Worksheet, ws As Worksheet
Dim Rws As Long, rng As Range, Prng As Range

Set sh = ActiveSheet
Set ws = Sheets("Sheet1")
Set Prng = ws.Range("B6")

With sh
Rws = .Range("B34").End(xlUp).Row
Set rng = .Range("B" & Rws & ":O" & Rws)
End With

rng.Copy Prng

End Sub
 
Upvote 0

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