工作中有时候需要给表格加目录,以便更快捷更直观的进入你想要的工作表,今天分享的代码很短,我尽量把它解释的更简单。
绿色字体是注释
1489568207658859.jpg
操作动态图
1489568215475845.gif
For Each是变量在某个集合里面循环,这个集合可以是单元格,可以是工作表,也可以是工作薄,客官可以自行修改代码进行尝试。代码如下:Dim a As Byte, d As ByteDim arr As Range, str As StringSub xjclj()a = ActiveWorkbook.Sheets.Countd = 2For Each arr In Selection.Resize(a - 1, 1)str = ActiveWorkbook.Sheets(d).NameActiveSheet.Hyperlinks.Add Anchor:=arr, Address:="", SubAddress:= _str & "!A1", TextToDisplay:=strd = d + 1NextEnd Sub |