|
参与一下。。。
- Sub ykcbf() '//2024.7.22
- Application.ScreenUpdating = False
- Set sh = ThisWorkbook.Sheets("Sheet1")
- Set d = CreateObject("Scripting.Dictionary")
- With sh
- col = .UsedRange.Columns.Count
- For j = 1 To col
- d(.Cells(1, j).Value) = j
- Next
- End With
- p = ThisWorkbook.Path & ""
- With Application.FileDialog(msoFileDialogFilePicker)
- .InitialFileName = p
- .Title = "请选择对应Excel文件"
- .AllowMultiSelect = False
- .Filters.Clear
- .Filters.Add "Excel文件", "*.xls*"
- If .Show Then f = .SelectedItems(1) Else Exit Sub
- End With
- Set wb = Workbooks.Open(f, 0)
- With wb.Sheets("Sheet1")
- r = .Cells(Rows.Count, 2).End(3).Row
- c = .UsedRange.Columns.Count
- arr = .[a1].Resize(r, c)
- End With
- wb.Close 0
- ReDim brr(1 To 10000, 1 To col)
- For i = 2 To UBound(arr)
- m = m + 1
- For j = 1 To UBound(arr, 2)
- s = arr(1, j): t = Val(d(s))
- If t > 0 Then
- brr(m, t) = arr(i, j)
- End If
- Next
- Next
- With sh
- .UsedRange.Offset(1).ClearContents
- .[a2].Resize(m, col) = brr
- End With
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|