(若是和其他不同軟體互動之問題 請記得一併填寫)
軟體:excel
版本:2013
這是別人寫的VBA, 現在想自己修改, 是從A檔案各個sheet不同位置
copy到B檔案各sheet不同位置, 有個表格是對照表
原本寫的檔案都得重新開啟A檔案和B檔案, 但其實原本都會同時開著,
不想每次run程式都要重開檔案, 上網研究好久, 依然不得其門而入
把Open刪掉, 程式就出現錯誤了@@
麻煩版上各位先進幫忙~~
Dim scWB As Workbook, tgWB As Workbook
Dim scWS As Worksheet, tgWS As Worksheet, ws As Worksheet
Dim row As Integer
Set ws = ThisWorkbook.Worksheets("XXX")
Set scWB = Application.Workbooks.Open(ws.Cells(1, 3).Value)
Set tgWB = Application.Workbooks.Open(ws.Cells(2, 3).Value)
For row = 4 To 63
If (Len(ws.Cells(row, 2).Value) > 0) Then
ws.Cells(row, 6).Value = "GO"
Set scWS = scWB.Worksheets(ws.Cells(row, 2).Value)
Set tgWS = tgWB.Worksheets(ws.Cells(row, 4).Value)
scWS.Range(ws.Cells(row, 3).Value).Copy
tgWS.Range(ws.Cells(row, 5).Value).PasteSpecial xlPasteValues
ws.Cells(row, 6).Value = "OK"
'scWB.Close
'tgWB.Close
End If