Dim A As Range, B As Range, N%
Dim X As New Application, FN$, xB As Workbook
For Each A In [$e$2:$bs$2] ''受評人數範圍-僅工號列
N = N + 1
FN = ThisWorkbook.Path & "\" & "5--自評完成資料" & "\" & A.Value & ".xlsm" ''本檔放在抓取檔案上一層
If Dir(FN) = "" Then GoTo 101
Set xB = X.Workbooks.Open(FN)
For Each B In [$e$4:$e$55] ''選擇回存的儲存格位置
On Error Resume Next
If Range(B.Value) Is Nothing Then GoTo 102
On Error GoTo 0
xB.Sheets(2).Range(B).Value = B(1, N + 1)
102: Next
xB.Close 1
101: Next
End Sub作者: 准提部林 時間: 2018-12-1 11:54
本帖最後由 准提部林 於 2018-12-1 11:57 編輯
還是用直接開啟檔案吧!!!
Sub 回存一次二次資料()
Dim A As Range, B As Range, N%
Dim FN$, xB As Workbook
For Each A In [$e$2:$bs$2] ''受評人數範圍-僅工號列
N = N + 1
FN = ThisWorkbook.Path & "\" & "5--自評完成資料" & "\" & A.Value & ".xlsm" ''本檔放在抓取檔案上一層
If Dir(FN) = "" Then GoTo 101
Application.ScreenUpdating = False
Set xB = Workbooks.Open(FN)
ThisWorkbook.Activate
For Each B In [$e$4:$e$55] ''選擇回存的儲存格位置
On Error Resume Next
If Range(B.Value) Is Nothing Then GoTo 102
On Error GoTo 0
B(1, N + 1)copy xB.Sheets(2).Range(B)
102: Next
xB.Close 1
101: Next
End Sub作者: dakiu 時間: 2018-12-3 09:51