Excel精英培训网

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

[已解决]求助用vab生成自动批量超链接

[复制链接]
发表于 2015-9-25 09:49 | 显示全部楼层 |阅读模式
求助大神们,sheet1名为首页,从sheet2开始就是00001-03000的页码,首页中有M列从M5开始是对应的页码编号00001-03000,求助如何利用VBA将M列这些有页码的单元格生成超链接到对应页码的sheet中。(就是页码00001超链接到00001名字的sheet中,sheet名字不会出现重复,页码编号也不会出现重复)
谢谢
最佳答案
2015-9-25 10:14
  1. Sub mulu()
  2.     Dim sht As Worksheet
  3.     [M5:M10000].ClearContents
  4.     For Each sht In Worksheets
  5.         If sht.Index > 1 Then
  6.             n = n + 1
  7.             ActiveSheet.Hyperlinks.Add anchor:=Cells(n + 4, "M"), Address:="", _
  8.                SubAddress:=sht.Name & "!A1", TextToDisplay:="'" & sht.Name
  9.         End If
  10.     Next
  11. End Sub
复制代码
excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
 楼主| 发表于 2015-9-25 09:50 | 显示全部楼层
回复

使用道具 举报

 楼主| 发表于 2015-9-25 10:00 | 显示全部楼层
添加不了附件,有需要的大神请联系我,我给各位大神发邮件过去。
回复

使用道具 举报

发表于 2015-9-25 10:14 | 显示全部楼层    本楼为最佳答案   
  1. Sub mulu()
  2.     Dim sht As Worksheet
  3.     [M5:M10000].ClearContents
  4.     For Each sht In Worksheets
  5.         If sht.Index > 1 Then
  6.             n = n + 1
  7.             ActiveSheet.Hyperlinks.Add anchor:=Cells(n + 4, "M"), Address:="", _
  8.                SubAddress:=sht.Name & "!A1", TextToDisplay:="'" & sht.Name
  9.         End If
  10.     Next
  11. End Sub
复制代码
回复

使用道具 举报

发表于 2015-9-25 10:14 | 显示全部楼层
请看附件。

工作簿1.rar

9.09 KB, 下载次数: 34

回复

使用道具 举报

 楼主| 发表于 2015-9-25 11:05 | 显示全部楼层
grf1973 发表于 2015-9-25 10:14

非常管用谢谢!!!!
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-3-29 09:44 , Processed in 0.421194 second(s), 12 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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