Macro Help - Copy and Paste Values Only in Same Cells

Devon19

New Member
Joined
May 12, 2022
Messages
1
Office Version
  1. 365
I am new to macros and am having trouble creating a macro that will copy a range of cells and then paste just the values back into the same cells. Basically I just need to get rid of the formulas and paste the value back into the same location.

I have tried the coding below, but I am getting an error that says "Run-time error '1004': PasteSpecial method of Range class failed." Can anyone help?

Sub CopyPaste()
Worksheets("Sheet1").Range("A1:G105").Copy
Worksheets("Sheet1").Range("A1:G105").PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
End Sub
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Devon, Let's get the ball rolling here. I just copied and pasted your program into a worksheet, and it did convert "=Rand()" formula into random numbers from A1 to G105. This leaves us with what kind of formulas you are trying to copy and paste. You need to post your worksheet using that xl28B.
 
Upvote 0
Code:
Worksheets("Sheet1").Range("A1:G105").Value = Worksheets("Sheet1").Range("A1:G105").Value
 
Upvote 0

Forum statistics

Threads
1,214,864
Messages
6,121,984
Members
449,058
Latest member
oculus

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