Copy and paste from one row to another

Patriot2879

Well-known Member
Joined
Feb 1, 2018
Messages
1,227
Office Version
  1. 2010
Platform
  1. Windows
Hi good afternoon, please can you help me, i have the code below where i am trying to copy the whole row (R) and paste into row (F) it works but then i get an error pop up for the .entirerow part. Please can you help.
VBA Code:
With Range("F2:F" & lr)
    .EntireRow.Copy Range("R2")
    .Rows(18).Copy Rows(6)
    .Value = .Value
End With
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Can you try explaining this again?
"F" and "R" are columns, not rows.

Maybe it would help to show us an example of what you want to do.

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Upvote 0
Hi this is my whole code below, i have data in column R, i want this copied to the last row. then i want this data copied into Column F. The code does work but i get a run time error 424 object required, and it highlights this line in yellow - .Copy = ("R2:R" & lr)

This is my whole code below, hope you can help?

Dim copySheet As Worksheet
Dim pasteSheet As Worksheet
Set copySheet = Worksheets("New")
Set pasteSheet = Worksheets("Combined")

Range("I2", Range("I2").End(xlDown)).Copy Range("B2")
Range("B2", Range("B2").End(xlDown)).NumberFormat = "0"
Range("J2", Range("J2").End(xlDown)).Copy Range("D2")
Range("R2", Range("R2").End(xlDown)).Copy Range("F2")
Dim lr As Long
lr = Cells(Rows.Count, "A").End(xlUp).Row
With Range("C2:C" & lr)
.Formula = "=VLOOKUP(B2,Old!B:C,2,FALSE)"
.Value = .Value
End With
With Range("E2:E" & lr)
.Formula = "=VLOOKUP(B2,Old!B:E,4,FALSE)"
.Value = .Value
End With
With Range("F2:F" & lr)
.Copy = ("R2:R" & lr)
.Value = .Value
End With
With Range("F2:F" & lr)
.EntireRow.Copy Range("R2")
.Rows(18).Copy Rows(6)
.Value = .Value
End With
With Range("F2:F" & lr)
.Formula = "=VLOOKUP(LEFT(F2,LEN(F2)-2),Postcodes!A:B,2,FALSE)"
.Value = .Value

With copySheet
.Range(.Cells(2, "A"), .Cells(.Cells(Rows.Count, "A").End(xlUp).Row, "AD")).Copy
End With

pasteSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
Sheets("Combined").Select
ActiveSheet.Range("B2").EntireColumn.Select
Selection.NumberFormat = "0"
ActiveSheet.Range("L2").EntireColumn.Select
Selection.NumberFormat = "dd/mm/yyyy"
ActiveSheet.Range("AD2").EntireColumn.Select
Selection.NumberFormat = "dd/mm/yyyy"
End With
End Sub[/CODE]
 
Last edited:
Upvote 0
VBA Code:
.Copy = ("R2:R" & lr)
is not a valid range reference.

Try:
VBA Code:
.Copy = Range("R2:R" & lr)
 
Upvote 0

Forum statistics

Threads
1,214,924
Messages
6,122,294
Members
449,077
Latest member
Rkmenon

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