◆打开Excel工作簿文档,按下ALT+F11组合键,打开VBA编辑器窗口
◆单击菜单栏上的“插入”——“模块”
◆将下面的代码拷贝到模块文本框中
1 2 3 4 5 6 7 8 |
Sub AutoGener() Dim nIndex As Integer Dim oRange As Range For nIndex = 2 To Sheets.Count Set oRange = Cells(Selection.Row + nIndex - 2, Selection.Column) oRange.Hyperlinks.Add Anchor:=oRange, Address:="", SubAddress:=Sheets(nIndex).Name & "!A1", TextToDisplay:=Sheets(nIndex).Name Next End Sub |
◆关闭保存后返回excel
◆插入一个按钮,然后在按钮上点右键->指定宏->AutoGener
◆然后选中一个单元格 点击刚刚添加的按钮,即可生成带链接的目录