Vba copy paste values

Biz

Well-known Member
Joined
May 18, 2009
Messages
1,773
Office Version
  1. 2021
Platform
  1. Windows
Dear All,

Is there a better way to copy and paste values refer to code below?

Code:
[SIZE=3][FONT=Calibri]   [COLOR=black] [COLOR=red]'Copy and Paste values[/COLOR]<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>[/COLOR][/FONT][/SIZE]
[COLOR=red][SIZE=3][FONT=Calibri][COLOR=black]    Range(Range("FU2"), Range("FU2").End(xlDown)).Copy<o:p></o:p>[/COLOR][/FONT][/SIZE][/COLOR]
[COLOR=red][SIZE=3][FONT=Calibri][COLOR=black]    Range("CZ2").PasteSpecial Paste:=xlPasteValues<o:p></o:p>[/COLOR][/FONT][/SIZE][/COLOR]

Biz
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Since you only want to move the values, just assign them instead of copy/pasting them...
Code:
With Range(Range("FU2"), Range("FU2").End(xlDown))
    Range("CZ2").Resize(.Rows.Count).Values = .Values
End With
 
Upvote 0
Hi Rick,

I get run-time error '438' object doesn't support this property or method.

Biz
 
Upvote 0
Hi Rick,

I tried again it should be value not values.

Thanks again mate.

Biz
 
Upvote 0
I'm guessing you retyped my code rather than copy/paste it and, in doing so, you omitted the "dot" in front of the ".Rows.Count" inside the Resize property... that dot is needed because we want the count of the rows to apply to the range in the With statement and not the number of rows on the entire sheet (which is the default).

Correction
--------------------
I just saw your last response... you are right... I mistakenly added an "s" at the end of the property name "Value". I'm glad you caught my mistake.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,574
Messages
6,179,629
Members
452,933
Latest member
patv

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