Macro to Range Value Data

howard

Well-known Member
Joined
Jun 26, 2006
Messages
5,748
Office Version
  1. 2019
Platform
  1. Windows
I have formula in Col Q2 onwards. I have written code to copy these from Q2 onwards to the last row containing a formula in Col Q to A2

However the last line of code is highlighted when trying running the macro

Your assistance is most appreciated


Sub RngVal ()
Dim Lr As Long
Lr = Cells(Rows.Count, 1).End(xlUp).Row
Range("Q2:Q" & Lr).PasteSpecial Paste:=xlPasteValues Destination:=Range("A2")
End Sub
 

Some videos you may like

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

Dryver14

Well-known Member
Joined
Mar 22, 2010
Messages
2,396
Code:
Sub RngVal()
 Dim Lr As Long
 Lr = Cells(Rows.Count, 1).End(xlUp).Row
 Range("Q2:Q" & Lr).Copy
 Range("A2").PasteSpecial xlValues
 Application.CutCopyMode = False
 End Sub
 

howard

Well-known Member
Joined
Jun 26, 2006
Messages
5,748
Office Version
  1. 2019
Platform
  1. Windows
Thanks for the help, which is most appreciated
 

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
36,877
Office Version
  1. 2010
Platform
  1. Windows
Thanks for the help, which is most appreciated
You should be able to do what you want by directly assigning the values without using copy/paste at all...
Code:
Sub RngVal()
  Dim Lr As Long
  Lr = Cells(Rows.Count, 1).End(xlUp).Row
  Range("A2:A" & Lr).Value = Range("Q2:Q" & Lr).Value
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,127,605
Messages
5,625,759
Members
416,135
Latest member
abtabt

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
Top