VBA paste as values - how to

Multi tool use


VBA paste as values - how to
I have some VBA code that copys a range from one sheet and then pastes it to another at the first blank line. What it is copying are vlookup formulas so when it pastes it pastes all 0's, how would I go about getting it to paste what it copies as values so the results are retained?
Code:
Private Sub PasteChartDataQtyCompare()
'This step pastes the range of values to the chart data tab
Sheets(1).Range("A6:J22").Copy _
Destination:=Sheets("Chart Data").Cells(Sheets("Chart Data").Rows.Count, 1).End(xlUp).Offset(1, 0)
End Sub
Range([destination range]).Value = Range([copy from range]).Value
You shouldn't be using destination. Use PasteSpecial xlPasteValues instead
– Daniel Souza
yesterday
so would I just replace Destination with PasteSpecial xlPasteValues? I have never used that and am a bit confused as to where to add it in the code
– user3496218
yesterday
3 Answers
3
Transfer the values directly bypassing the clipboard.
Private Sub PasteChartDataQtyCompare()
'This step pastes the range of values to the chart data tab
with workSheets(1).Range("A6:J22")
workSheets("Chart Data").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).resize(.rows.count,.columns.count) = .value
end with
End Sub
Indeed, this is the more efficient approach.
– jeffreyweir
yesterday
You want to use
.PasteSpecial xlPasteValues
A similar question was answered in detail here: Excel VBA Copy Paste Values only( xlPasteValues )
thanks. I am not familiar with that, would I just add it to the end of the code?
– user3496218
yesterday
Use Range Method "Range.PasteSpecial xlPasteValue"
Example:
Sheets("Sheet1").Columns("A").Copy
Sheets("Sheet2").Columns("B").PasteSpecial xlPasteValues
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Just set the ranges equal to eachother (note they have to be the same size I believe), like
Range([destination range]).Value = Range([copy from range]).Value
– BruceWayne
yesterday