在文件之间复制列的宏

时间:2018-12-13 14:17:25

标签: excel vba

我正在尝试将列从一个文件复制到另一个文件,但一直出现运行时错误。我认为问题出在文件路径上。它在共享工作站上,但是我已将文件保存到用户桌面。我需要更改文件路径吗?谢谢

Sub PlatingSheet()

Dim sourceColumn As Range, targetColumn As Range

Set sourceColumn = Workbooks("\\in-ge-file\users\tbever\Desktop\VBA\Plating 
Sheets\Copy - 24605_17 QC Results and Notes.xlsm").Worksheets(1).Columns("A")

Set targetColumn = Workbooks("\\in-ge-file\users\tbever\Desktop\VBA\Plating 
Sheets\Copy - 1.1Unified_Plating_Template.xlsm").Worksheets(1).Columns("A")
sourceColumn.Copy Destination:=targetColumn

End Sub"

1 个答案:

答案 0 :(得分:0)

工作簿的引用Name不在那里FullName

Sub PlatingSheet()

    Dim sourceColumn As Range, targetColumn As Range

    Set sourceColumn = Workbooks("Copy - 24605_17 QC Results and Notes.xlsm").Worksheets(1).Columns("A")
    Set targetColumn = Workbooks("Copy - 1.1Unified_Plating_Template.xlsm").Worksheets(1).Columns("A")
    sourceColumn.Copy Destination:=targetColumn

End Sub