View Full Version : Solved: Alter code to only copy values without formulas
Barryj
01-14-2009, 09:53 AM
I am using this code to copy date from one work book to another, but it is also copying formulas from the selected cells.
What do I have to do to alter the code to stop it form also copying formulas.
I tried
Set RngCopy.Values
But this was bugging out.
Sub Copy()
Dim RngCopy As Range
Dim RngPaste As Range
Set RngCopy = Workbooks("Results.xls").Sheets("Final Results").Range("A1:I42")
Set RngPaste = Workbooks("Results Email.xls").Sheets("Results Sheet").Range("A1:I42")
RngCopy.Copy RngPaste
RngCopy.Copy RngPaste
End Sub
Any thoughts?
Thanks very much
nst1107
01-14-2009, 09:55 AM
Use .PasteSpecial (xlValues)
Barryj
01-14-2009, 10:20 AM
I tried changing the RngPaste to RngpasteSpecial but it is still copying the formulas?
Is that what you were refering to do?
Thanks
Simon Lloyd
01-14-2009, 10:21 AM
I see what you were trying to do with the 2nd RngPaste, if you are not going to use .PasteSpecial then what you really needed was:Sub Copy()
Dim RngCopy As Range
Dim RngPaste As Range
Set RngCopy = Workbooks("Results.xls").Sheets("Final Results").Range("A1:I42")
Set RngPaste = Workbooks("Results Email.xls").Sheets("Results Sheet").Range("A1:I42")
RngCopy.Copy RngPaste
RngPaste = RngPaste.Value
End Sub
I am using this code to copy date from one work book to another, but it is also copying formulas from the selected cells.
What do I have to do to alter the code to stop it form also copying formulas.
I tried
Set RngCopy.Values
But this was bugging out.
Sub Copy()
Dim RngCopy As Range
Dim RngPaste As Range
Set RngCopy = Workbooks("Results.xls").Sheets("Final Results").Range("A1:I42")
Set RngPaste = Workbooks("Results Email.xls").Sheets("Results Sheet").Range("A1:I42")
RngCopy.Copy RngPaste
RngCopy.Copy RngPaste
End Sub
Any thoughts?
Thanks very much
Barryj
01-14-2009, 10:31 AM
That has done the trick, thanks very much Simon, have marked this as solved.
Thanks again for yor assistance.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.