Excel VBA粘贴特殊值

时间:2016-02-10 08:46:39

标签: excel vba excel-vba

我需要编辑以下代码,将数据复制到另一个工作簿,仅作为值

Sub CopyColumnToWorkbook()
Dim sourceColumn As Range, targetColumn As Range

Set sourceColumn = Workbooks("Source.xls").Worksheets(2).Columns("A:E")
Set targetColumn = Workbooks("Target.xls").Worksheets(1).Columns("A")

sourceColumn.Copy Destination:=targetColumn
End Sub

1 个答案:

答案 0 :(得分:2)

试试这段代码:

Sub CopyColumnToWorkbook()
     Dim sourceColumn As Range, targetColumn As Range

     Set sourceColumn = Workbooks("Source.xls").Worksheets(2).Columns("A:E")
     Set targetColumn = Workbooks("Target.xls").Worksheets(1).Columns("A")

     sourceColumn.Copy
     targetColumn.PasteSpecial xlPasteValues
     Application.CutCopyMode = False

  End Sub