|
参与一下。。。
- Sub ykcbf() '//2024.4.1
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Set d = CreateObject("Scripting.Dictionary")
- Set sh = ThisWorkbook.Sheets("Sheet1")
- With sh
- r = .Cells(Rows.Count, 1).End(3).Row
- c = .UsedRange.Columns.Count
- arr = .[a1].Resize(r, c)
- End With
- For j = 1 To UBound(arr, 2)
- s = arr(1, j)
- d(s) = ""
- Next
- p = ThisWorkbook.Path
- f = p & "\源文件.xls"
- Set wb = Workbooks.Open(f, 0)
- With wb.Sheets("Sheet1")
- arr = .UsedRange
- wb.Close False
- End With
- For j = 1 To UBound(arr, 2)
- s = arr(1, j)
- d(s) = ""
- Next
- For Each k In d.keys
- n = n + 1
- d(k) = n
- Next
- ReDim brr(1 To UBound(arr), 1 To d.Count)
- For i = 2 To UBound(arr)
- If arr(i, 1) <> Empty Then
- m = m + 1
- For j = 1 To UBound(arr, 2)
- s = arr(1, j)
- brr(m, d(s)) = arr(i, j)
- Next
- End If
- Next
- With sh
- .[a1].Resize(1, d.Count) = d.keys
- r = .Cells(Rows.Count, 1).End(3).Row
- .Cells(r + 1, 1).Resize(m, d.Count) = brr
- End With
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
评分
-
2
查看全部评分
-
|