Code check

Miya

Well-known Member
Joined
Nov 29, 2008
Messages
662
Hi, how can i use paste values in the below code when copying data to another sheet, i get an error when using the below.


Code:
Sub test()
Dim LR As Long
With Sheets("Rec")
LR = .Cells(Rows.Count, 1).End(xlUp).Row
    With .Range("E8:E" & LR)
        .Copy Destination:=Sheets("Data").Range("A9")
        .PasteSpecial xlPasteValues
    End With
End With
    
End Sub
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Hi Miya,

This seems to work for me...

Code:
Sub test()
Dim LR As Long
LR = Range("E" & Rows.Count).End(xlUp).Row
Sheets("Rec").Range("E8:E" & LR).Copy Destination:=Sheets("Data").Range("A9")
End Sub
 
Upvote 0
Hi Miya,

This seems to work for me...

Code:
Sub test()
Dim LR As Long
LR = Range("E" & Rows.Count).End(xlUp).Row
Sheets("Rec").Range("E8:E" & LR).Copy Destination:=Sheets("Data").Range("A9")
End Sub

But if i have columns in the active worksheet which are formatted green then wouldn't the code copy the format over to sheet data?
 
Upvote 0
Okay...how about this...

Code:
Sub test()
Dim LR As Long
LR = Range("E" & Rows.Count).End(xlUp).Row
Sheets("Rec").Range("E8:E" & LR).Copy
With Sheets("Data").Range("A9")
.PasteSpecial Paste:=xlPasteValues
End With
Application.CutCopyMode = False
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,894
Messages
6,122,124
Members
449,066
Latest member
Andyg666

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