2,463
社区成员
发帖
与我相关
我的任务
分享
Sub demo()
Dim i As Long, arr, tempArr, d As Object
Set d = CreateObject("scripting.dictionary")
arr = Range(Cells(5, 2), Cells(Cells(Rows.Count, 1).End(xlUp).Row, 7)).Value
For i = 1 To UBound(arr)
d(arr(i, 1) & "") = i
Next i
With Application.FileDialog(msoFileDialogOpen)
.AllowMultiSelect = True
.Filters.Clear
.Filters.Add "Excel 文件(*.xl*)", "*.xl*"
.Title = "选择汇总表"
.Show
On Error Resume Next
For i = 1 To .SelectedItems.Count
With Workbooks.Open(.SelectedItems(i))
With .Sheets("AC")
tempArr = .Range("A6:E11").Value
arr(d(tempArr(1, 1) & ""), 2) = tempArr(1, 5)
arr(d(tempArr(1, 1) & ""), 3) = tempArr(2, 5)
arr(d(tempArr(1, 1) & ""), 4) = tempArr(3, 5)
arr(d(tempArr(1, 1) & ""), 5) = tempArr(4, 5)
arr(d(tempArr(1, 1) & ""), 6) = tempArr(5, 5)
arr(d(tempArr(1, 1) & ""), 7) = tempArr(6, 5)
End With
.Close False
End With
Next i
Err.Number = 0
On Error GoTo 0
Range(Cells(5, 2), Cells(Cells(Rows.Count, 1).End(xlUp).Row, 7)).Value = arr
End With
End Sub