|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
参与一下。。。
- Sub ykcbf() '//2024.5.9
- Set fso = CreateObject("scripting.filesystemobject")
- Set d = CreateObject("Scripting.Dictionary")
- Application.ScreenUpdating = False
- Set sh = ThisWorkbook.Sheets("Sheet1")
- p = ThisWorkbook.Path & "\文件"
- For Each f In fso.GetFolder(p).Files
- If InStr(f.Name, ThisWorkbook.Name) = 0 Then
- fn = fso.GetBaseName(f)
- d(fn) = f
- End If
- Next f
- With sh
- r = .Cells(Rows.Count, 1).End(3).Row
- For i = 2 To r
- s = CStr(.Cells(i, 1))
- If d.exists(s) Then
- .Cells(i, 2) = d(s)
- .Hyperlinks.Add Anchor:=.Cells(i, 1), Address:=d(s)
- End If
- Next
- End With
- Application.ScreenUpdating = True
- End Sub
复制代码
|
|