Macro to Range Value Data

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,568
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

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
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,215,740
Messages
6,126,585
Members
449,319
Latest member
iaincmac

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