|
楼主 |
发表于 2024-1-14 13:35
|
显示全部楼层
VBA转的时候没注意格式,现在可以了
Public Sub 创建工作表超链接()
Dim sh, j, i, wr, cz
Dim d As New Dictionary(Of Object, String)
If (xlapp.Worksheets("汇总表").Cells(4, 2).value = "工作表名") Then
GoTo 100
Else
Exit Sub
End If
100:
sh = xlapp.Sheets("汇总表")
j = xlapp.Worksheets("汇总表").index
cz = 6 - j '第6行与汇总表序列号的差值
wr = sh.Cells(xlapp.Rows.Count, 2).End(Excel.XlDirection.xlUp).Row
With sh
For i = 6 To wr
sh.hyperlinks.add(anchor:= .range("b" & i), address:="", subaddress:="'" & xlapp.Sheets(i - cz + 1).name & "'!a1", screentip:=xlapp.Sheets(i - cz + 1).name)
sh.hyperlinks.add(anchor:= .range("d" & i), address:="", subaddress:="'" & xlapp.Sheets(i - cz + 1).name & "'!a1", screentip:=xlapp.Sheets(i - cz + 1).name)
xlapp.Sheets(i - cz + 1).range("n8").hyperlinks.add(anchor:=xlapp.Sheets(i - cz + 1).range("n8"), address:="", subaddress:="'" & xlapp.Sheets(j).name & "'!a4", TextToDisplay:="返回目录")
Next
End With
End Sub |
|