0

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

user3496218
  • 185
  • 3
  • 5
  • 19
  • 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 Jul 25 '18 at 21:37
  • You shouldn't be using destination. Use PasteSpecial xlPasteValues instead – Daniel Souza Jul 25 '18 at 21:41
  • 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 Jul 25 '18 at 21:42

3 Answers3

4

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
2

Use Range Method "Range.PasteSpecial xlPasteValue"

Example:

Sheets("Sheet1").Columns("A").Copy
Sheets("Sheet2").Columns("B").PasteSpecial xlPasteValues
Tina Lo
  • 21
  • 3
1

You want to use

.PasteSpecial xlPasteValues

A similar question was answered in detail here: Excel VBA Copy Paste Values only( xlPasteValues )