|
50金钱
Private Sub Workbook_Open()
Dim S, I As Integer
S = Me.Worksheets.Count
Sheet1.Activate
Sheet1.Cells(1, 1) = "序号"
Sheet1.Cells(1, 2) = "名称"
For I = 1 To S - 1
Range("B" & I + 1).Hyperlinks.Add Anchor:=Range("B" & I + 1), Address:="", SubAddress:=ThisWorkbook.Sheets(I).Name + "!A1"
Sheet1.Cells(I + 1, 1) = I
Sheet1.Cells(I + 1, 2) = Me.Sheets(I).Name
Next I
End Sub
=====================================================
以上代码可以解决自动生成目录并链接到对应的Sheet
但是当工作表的名字中有特殊字符的时候其对应的超链接就会出错,那位大虾可以帮我解决啊?
为何还没人帮我解决? |
最佳答案
查看完整内容
SubAddress:=ThisWorkbook.Sheets(I).Name
改为如下:
SubAddress:="'" & ThisWorkbook.Sheets(I).Name & "'"
|