excel 将内容超链接添加到图纸

cld4siwp  于 2023-05-19  发布在  其他
关注(0)|答案(1)|浏览(170)

不知道有没有人能帮我。
我有超过20张我已经在第一张创建了一个内容超链接。现在我想将内容超链接分配给工作表。因此,当我在表20上并点击表20中的链接时,它会把我带回内容表。它适用于活动工作表,但不适用于其余工作表。我做错了什么?

Sub AddContentLinctoSheets111()

Dim WS_Count As Integer
Dim I As Integer

WS_Count = ActiveWorkbook.Worksheets.Count

For I = 1 To WS_Count

Range("G1").Select
      ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:= _
        "CONTENTS!A1", TextToDisplay:="CONTENTS!A1"
Next I

End Sub
jdzmm42g

jdzmm42g1#

Sub AddLinkstoAllSheets()
       Dim ws As Worksheet
         For Each ws In ActiveWorkbook.Worksheets
          If ws.Name <> "CONTENTS" Then
            ws.Hyperlinks.Add _
              Anchor:=ws.Range("G1"), _
              Address:="", _
              SubAddress:="Contents!A1", _
              TextToDisplay:="Contains Page"
        End If
    Next ws
End Sub

相关问题