为excel的sheet创建index目录及页码和链接的vba(无错版,不会出现链接无效)
Sub CreatSheetsIndex()
Dim r, c, i, b
r = Selection.Row()
c = Selection.Column()
b = InputBox("请问你要从第几个sheet开始编制INDEX: ")
For i = b To Worksheets.Count
Cells(r + i - b, c) = Worksheets(i).Name
Next i
For i = b To Worksheets.Count
t = Cells(r + i - b, c)
Cells(r + i - b, c).Select
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:="'" & t & "'!A1", ScreenTip:="进入", TextToDisplay:=t
Next i
End Sub
帮一个搞工程材料的朋友写,应该有用的。顺便分享下。
Dim r, c, i, b
r = Selection.Row()
c = Selection.Column()
b = InputBox("请问你要从第几个sheet开始编制INDEX: ")
For i = b To Worksheets.Count
Cells(r + i - b, c) = Worksheets(i).Name
Next i
For i = b To Worksheets.Count
t = Cells(r + i - b, c)
Cells(r + i - b, c).Select
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:="'" & t & "'!A1", ScreenTip:="进入", TextToDisplay:=t
Next i
End Sub
帮一个搞工程材料的朋友写,应该有用的。顺便分享下。