我需要编辑以下代码,将数据复制到另一个工作簿,仅作为值
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
答案 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