Macro to Range Value Data

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,563
Office Version
  1. 2021
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
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
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
 
Upvote 0
Thanks for the help, which is most appreciated
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,214,990
Messages
6,122,625
Members
449,093
Latest member
catterz66

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