|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
参与一下。。。
- Sub ykcbf() '//2025.1.12
- Set fso = CreateObject("scripting.filesystemobject")
- Set d = CreateObject("Scripting.Dictionary")
- Application.ScreenUpdating = False
- Set sh = ThisWorkbook.Sheets(1)
- p = ThisWorkbook.Path & ""
- Dim tm: tm = Timer
- On Error Resume Next
- For Each f In fso.GetFolder(p).Files
- If LCase$(f.Name) Like "*.xls*" Then
- If InStr(f.Name, ThisWorkbook.Name) = 0 Then
- fn = fso.GetBaseName(f)
- Set wb = Workbooks.Open(f, 0)
- arr = wb.Sheets(1).UsedRange
- wb.Close False
- For i = 2 To UBound(arr)
- For j = 3 To 4
- s = arr(i, 1) & "|" & arr(i, 2) & "|" & arr(1, j)
- d(s) = arr(i, j)
- Next
- Next
- End If
- End If
- Next f
- With sh
- .UsedRange.Offset(1, 2).ClearContents
- arr = .UsedRange
- For i = 2 To UBound(arr)
- For j = 3 To UBound(arr, 2)
- s = arr(i, 1) & "|" & arr(i, 2) & "|" & arr(1, j)
- If d.exists(s) Then
- arr(i, j) = d(s)
- End If
- Next
- Next
- .UsedRange = arr
- End With
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "共用时:" & Format(Timer - tm) & "秒!"
- End Sub
复制代码
|
评分
-
2
查看全部评分
-
|