|
Option Explicit
Sub TEST6()
Dim ar, br, i&, j&, k&, dic As Object, wks As Worksheet, strFileName$
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set dic = CreateObject("Scripting.Dictionary")
Set wks = Worksheets(1)
ar = Worksheets(2).[A1].CurrentRegion.Value
For i = 2 To UBound(ar)
strFileName = ar(i, 1)
For j = 2 To UBound(ar, 2)
dic(ar(1, j)) = ar(i, j)
Next j
wks.Copy
With ActiveWorkbook
With Worksheets(1)
br = .[A1].CurrentRegion.Value
For k = 2 To UBound(br): br(k, 2) = dic(br(k, 1)): Next
.[A1].CurrentRegion.Value = br
End With
.SaveAs ThisWorkbook.Path & "\" & strFileName
.Close
End With
Next i
Set dic = Nothing: Set wks = Nothing
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Beep
End Sub
|
|