Sub a()
Dim wb1 As Object
Dim x As Integer
Dim i As Integer
Dim z As Integer
Dim s As String
Path = "C:\Users\1111\Desktop\CommProtocol.xlsx" ’输入地址
Set wb1 = CreateObject(Path)
For x = 5 To 53
For i = 1 To wb1.Worksheets.Count
s = wb1.Worksheets(i).Name
If InStr(1, Cells(4, x), s) > 0 Then ‘如果含有文件名,就设置超链接
For z = 5 To 170
If Cells(z, x) <> "" Then
ActiveSheet.Hyperlinks.Add Anchor:=Cells(z, x), Address:= _
Path, _
SubAddress:="'" & wb1.Worksheets(i).Name & "'" & "!A1"
End If
Next
End If
Next
Next
End Sub
VBA遍历另一个excel的文件名设置超链接
于 2022-07-21 17:16:06 首次发布