ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Paste values only (https://www.excelbanter.com/excel-programming/419926-paste-values-only.html)

GLHEC-BLS

Paste values only
 
I am trying to write code to paste the contents of a range of cells on sheet
1 to a range of cells on sheet 2 but all it is pasting is a #REF error. I
assume this is becuase it is pasting the formula in the cells on sheet 1 and
not the values only. Is their a pasteSpecial method to paste teh values of
the cells only?

Bobt

Paste values only
 
Here's the line to add once you have selected where you want to paste.

Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

"GLHEC-BLS" wrote:

I am trying to write code to paste the contents of a range of cells on sheet
1 to a range of cells on sheet 2 but all it is pasting is a #REF error. I
assume this is becuase it is pasting the formula in the cells on sheet 1 and
not the values only. Is their a pasteSpecial method to paste teh values of
the cells only?


Gary''s Student

Paste values only
 
Sub Macro1()
Range("A1:D7").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
End Sub

right from the recorder
--
Gary''s Student - gsnu200813


"GLHEC-BLS" wrote:

I am trying to write code to paste the contents of a range of cells on sheet
1 to a range of cells on sheet 2 but all it is pasting is a #REF error. I
assume this is becuase it is pasting the formula in the cells on sheet 1 and
not the values only. Is their a pasteSpecial method to paste teh values of
the cells only?



All times are GMT +1. The time now is 07:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com