Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 2265|回复: 2

[已解决]创建表格目录超链接 出问题,提示引用有误, 有附件,请大侠帮忙

[复制链接]
发表于 2013-12-27 10:58 | 显示全部楼层 |阅读模式
创建表格目录超链接 出问题,提示引用有误, 有附件,请大侠帮忙



不知道为什么 老是提示错误,


请大侠帮忙修改语句
最佳答案
2013-12-27 11:29
Sub mu()
    Dim s%, Rng As Range, x

    With Sheets("目录")
        .Activate
        For i = 3 To Sheets.Count
            x = Sheets(i).Name
            Sheets(1).Hyperlinks.Add Anchor:=Cells(i, 1), Address:="", SubAddress:="'" & x & "'!A1"
            .Cells(i, 1) = x
            .Cells(i, 2) = Sheets(x).Cells(4, 7)
            .Cells(i, 3) = Sheets(x).Cells(4, 9)
            .Cells(i, 4) = Sheets(x).Cells(5, 7)
            .Cells(i, 5) = Sheets(x).Cells(5, 9)
            .Cells(i, 6) = Sheets(x).Cells(4, 3)
            .Cells(i, 7) = Sheets(x).Cells(4, 5)
            .Cells(i, 8) = Sheets(x).Cells(5, 3)
            .Cells(i, 9) = Sheets(x).Cells(5, 5)
            .Cells(i, 10) = Sheets(x).Cells(2, 5)
            .Cells(i, 11) = Sheets(x).Cells(2, 3)
        Next
        .Range("b:iv").EntireColumn.ColumnWidth = 14
    End With
End Sub

问题记录 - 副本.zip

14.09 KB, 下载次数: 13

excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
发表于 2013-12-27 11:29 | 显示全部楼层    本楼为最佳答案   
Sub mu()
    Dim s%, Rng As Range, x

    With Sheets("目录")
        .Activate
        For i = 3 To Sheets.Count
            x = Sheets(i).Name
            Sheets(1).Hyperlinks.Add Anchor:=Cells(i, 1), Address:="", SubAddress:="'" & x & "'!A1"
            .Cells(i, 1) = x
            .Cells(i, 2) = Sheets(x).Cells(4, 7)
            .Cells(i, 3) = Sheets(x).Cells(4, 9)
            .Cells(i, 4) = Sheets(x).Cells(5, 7)
            .Cells(i, 5) = Sheets(x).Cells(5, 9)
            .Cells(i, 6) = Sheets(x).Cells(4, 3)
            .Cells(i, 7) = Sheets(x).Cells(4, 5)
            .Cells(i, 8) = Sheets(x).Cells(5, 3)
            .Cells(i, 9) = Sheets(x).Cells(5, 5)
            .Cells(i, 10) = Sheets(x).Cells(2, 5)
            .Cells(i, 11) = Sheets(x).Cells(2, 3)
        Next
        .Range("b:iv").EntireColumn.ColumnWidth = 14
    End With
End Sub
回复

使用道具 举报

发表于 2013-12-27 12:02 | 显示全部楼层
  1. Option Explicit
  2. Sub AutoGenerateHyperlinks()
  3.     Dim i%, oRange As Range
  4.     For i = 3 To Sheets.Count
  5.         Set oRange = Cells(Selection.Row + i - 2, Selection.Column)
  6.         oRange.Hyperlinks.Add Anchor:=oRange, Address:="", SubAddress:="'" & Sheets(i).Name & "'!A1", TextToDisplay:=Sheets(i).Name
  7.     Next
  8. End Sub
复制代码
选好单元格  运行
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-4-25 14:48 , Processed in 0.391270 second(s), 10 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表