excel中批量创建超链接代码(连接当前文档中的sheet),在sheet1中B列中要创建一系列的超链接,链接的内容是本文档中的其他sheet,如下图,在sheet1下创建宏,代码如下。
Sub 宏1()
Dim temp, temp2
Dim i, j
j = 1
For i = 5 To 74
temp = "‘G" & j & "‘!A1"
temp2 = "G" & j
Range("B" & i).Select
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:=temp, TextToDisplay:="G" & j
j = j + 1
Next
End Sub
在每一个sheet的第一个单元格中创建返回sheet1的B列所对应的链接单元格。
Sub 宏2()
Dim temp, temp2, i, j
j = 1
For i = 5 To 74
temp = "sheet1!B" & i
temp2 = "G" & j
Sheets(temp2).Select
ActiveCell.FormulaR1C1 = ""
Range("A1").Select
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:=temp, TextToDisplay:="返回"
j = j + 1
Next
End Sub
时间: 2024-10-10 05:28:27