跳到主要内容

如何在Excel中一次更改多个超链接路径?

出于某种目的,您可以为工作表中的数据创建多个超链接,并且所有超链接都链接到相同的文件路径或地址,但是现在,您需要一次用另一个地址替换该超链接路径。 单独更改超链接的路径可能会浪费大量时间,是否有解决此问题的快速方法?

使用VBA代码一次更改工作表中的多个超链接路径

一次更改一个工作表/工作簿/多个工作表/选择中的多个超链接路径,具有惊人的功能


使用VBA代码一次更改工作表中的多个超链接路径

假设您具有与以下屏幕快照相同的超链接数据列表,并且具有VBA代码,则可以使用新的VBA代码快速替换工作表中的旧文件路径或地址。

1. 按住 ALT + F11 键,然后打开 Microsoft Visual Basic应用程序窗口.

2. 点击 插页 > 模块,然后将以下宏粘贴到 模块窗口.

VBA代码:一次更改多个超链接路径

Sub ReplaceHyperlinks()
'Updateby Extendoffice
Dim Ws As Worksheet
Dim xHyperlink As Hyperlink
Dim xOld As String, xNew As String
xTitleId = "KutoolsforExcel"
Set Ws = Application.ActiveSheet
xOld = Application.InputBox("Old text:", xTitleId, "", Type:=2)
xNew = Application.InputBox("New text:", xTitleId, "", Type:=2)
Application.ScreenUpdating = False
For Each xHyperlink In Ws.Hyperlinks
    xHyperlink.Address = Replace(xHyperlink.Address, xOld, xNew)
Next
Application.ScreenUpdating = True
End Sub

3。 然后按 F5 键运行此代码,并在提示框中输入您的旧超链接地址到 旧文字 框。 看截图:

4。 点击 OK,然后会弹出另一个提示框,提醒您输入要使用的新超链接地址。

5。 然后点击 OK,所有相同的旧超链接地址立即被新的替换。 查看屏幕截图:


一次更改一个工作表/工作簿/多个工作表/选择中的多个超链接路径,具有惊人的功能

如果要替换选区,多个工作表,当前工作簿或多个工作簿中的超链接路径,该怎么办? 用 查找和替换 的特点 Kutools for Excel,您可以快速处理此任务。

请注意:申请这个 查找和替换 实用程序,首先,您应该下载 Kutools for Excel,然后快速轻松地应用该功能。

安装后 Kutools for Excel,请这样做:

1。 点击 库工具 > 旅游导航 ,请参见屏幕截图:

2。 在开 旅游导航 窗格中单击 查找和替换 标签,在 查找和替换 窗格中单击 更换 标签,然后执行以下操作:

  • 将您要查找的旧超链接文本输入到 查找内容 文本框,然后在其中键入您要替换的新超链接文本。 更换 文本框;
  • 指定您要查找的范围并从中替换超链接路径 下拉列表;
  • 然后,从“查找范围”下拉列表中选择“超链接”;
  • 最后点击 找到所有 按钮,包含特定超链接文本的所有相应单元格都已列在底部列表框中。

3。 然后,点击 “全部替换” 按钮,旧的超链接路径已立即更改为新的,请参见屏幕截图:

点击下载 Kutools for Excel 免费试用!


更多相关文章:

  • 从超链接中提取实际地址
  • 假设您有一系列包含超链接的单元格,现在您需要查看超链接的实际目的地,并从超链接中提取它们,如下面的屏幕截图所示。 有没有简单的方法可以快速解决此问题?
  • 在Excel中将图像URL转换为实际图像
  • 如果现在在A列中有一个图像URL地址列表,那么您想从URL下载相应的图片,并将其显示在相邻的B列中,如左图所示。 在Excel中,如何快速,轻松地从图像URL中提取实际图片?
  • 在Excel中将网址文本转换为可点击的超链接
  • 假设您的工作表中有多个URL,但是它们没有链接,现在您需要将所有未链接的URL转换为可单击的超链接,如下面的屏幕快照所示。 当然,您可以一次双击它们以使其可单击,但是如果有很多URL,这将很耗时。 如何在Excel中自动将多个未链接的URL转换为可单击的超链接?
  • 从Excel超链接打开PDF文档的特定页面
  • 将单元格链接到PDF文件时,通常,单击以打开超链接时,将转到PDF文件的第一页。 如果您需要通过单击超链接直接跳到PDF文件的特定页面,则本文可能会对您有所帮助。

最佳办公生产力工具

🤖 Kutools 人工智能助手:基于以下内容彻底改变数据分析: 智能执行   |  生成代码  |  创建自定义公式  |  分析数据并生成图表  |  调用 Kutools 函数...
热门特色: 查找、突出显示或识别重复项   |  删除空白行   |  合并列或单元格而不丢失数据   |   不使用公式进行四舍五入 ...
超级查询: 多条件VLookup    多值VLookup  |   跨多个工作表的 VLookup   |   模糊查询 ....
高级下拉列表: 快速创建下拉列表   |  依赖下拉列表   |  多选下拉列表 ....
列管理器: 添加特定数量的列  |  移动列  |  切换隐藏列的可见性状态  |  比较范围和列 ...
特色功能: 网格焦点   |  设计图   |   大方程式酒吧    工作簿和工作表管理器   |  资源库 (自动文本)   |  日期选择器   |  合并工作表   |  加密/解密单元格    按列表发送电子邮件   |  超级筛选   |   特殊过滤器 (过滤粗体/斜体/删除线...)...
前 15 个工具集12 文本 工具 (添加文本, 删除字符,...)   |   50+ 图表 类型 (甘特图,...)   |   40+ 实用 公式 (根据生日计算年龄,...)   |   19 插入 工具 (插入二维码, 从路径插入图片,...)   |   12 转化 工具 (小写金额转大写, 货币兑换,...)   |   7 合并与拆分 工具 (高级组合行, 分裂细胞,...)   |   ... 和更多

使用 Kutools for Excel 增强您的 Excel 技能,体验前所未有的效率。 Kutools for Excel 提供了 300 多种高级功能来提高生产力并节省时间。  单击此处获取您最需要的功能...

产品描述


Office Tab 为 Office 带来选项卡式界面,让您的工作更加轻松

  • 在Word,Excel,PowerPoint中启用选项卡式编辑和阅读,发布者,Access,Visio和Project。
  • 在同一窗口的新选项卡中而不是在新窗口中打开并创建多个文档。
  • 每天将您的工作效率提高50%,并减少数百次鼠标单击!
Comments (47)
Rated 5 out of 5 · 1 ratings
This comment was minimized by the moderator on the site
This might be an older article, but was exactly what I needed. Thank you!
This comment was minimized by the moderator on the site
hi
thanks man you helped me a lot
This comment was minimized by the moderator on the site
I downloaded this and gave it a try and it did nothing. My hyperlinks look like this: file///\\server\shared\PO\CY2021\25079.pdf. I'm trying to change "server" to "server1" after a migration. I do the find/replace and choose Hyperlink, execute it, and... nothing happens. 
Any ideas?
This comment was minimized by the moderator on the site
Hello John,Sorry to hear that. The reason why the find/replace function didn't work is that your hyperlink file///\\server\shared\PO\CY2021\25079.pdf is not valid. According to the Excel dialog box, it shows the address of this site is not valid. Check the address and try again.
Then when I change your hyperlink to http://file///\\server\shared\PO\CY2021\25079.pdf, the find/replace function works perfectly. Please have a try. Have a nice day.
Sincerely,Mandy
This comment was minimized by the moderator on the site
Muchas gracias, me ahorraste mucho tiempo actualizando hipervinculos!
This comment was minimized by the moderator on the site
Muito obrigado! Você me salvou dezenas de horas de sono que seriam perdidas atualizando links.
This comment was minimized by the moderator on the site
Would it be possible to have a version to set a macro in power point for update links to excel, happens that monthly we need to link the power point presentation to a new excel in a new location. I have to do it one by one and it takes hours! MANY THANKS!!!!

This comment was minimized by the moderator on the site
Thankyou so much for the vba fix. I knew there had to be an easy way to fix my hyperlink problem and you provided it :) I am extremely grateful.
This comment was minimized by the moderator on the site
Many thanks for the VBA code to change multiple hyperlink paths at once. Would it be possible to have a version that would go through the different tabs (worksheets) of the xls workbook, as the current version only seems to change the links in the active worksheet? Would be highly appreciated!

Thanks,

Schweppy
This comment was minimized by the moderator on the site
Hello, Schweppy,
The below code can help you to replace the hyperlinks in all sheets, please try.

Sub ReplaceHyperlinks()
Dim xWs As Worksheet
Dim xWss As Sheets
Dim xHyperlink As Hyperlink
Dim xOld As String, xNew As String
xTitleId = "KutoolsforExcel"
Set WS = Application.ActiveSheet
xOld = Application.InputBox("Old text:", xTitleId, "", Type:=2)
xNew = Application.InputBox("New text:", xTitleId, "", Type:=2)
Application.ScreenUpdating = False
Set xWss = Application.ActiveWorkbook.Worksheets
For Each xWs In xWss
For Each xHyperlink In xWs.Hyperlinks
xHyperlink.Address = Replace(xHyperlink.Address, xOld, xNew)
Next
Next xWs
Application.ScreenUpdating = True
End Sub
This comment was minimized by the moderator on the site
This is amazing!!! Thank you for posting the code that works for all of the worksheets. I had the hardest time finding this and couldn't figure out how to create it myself. Thank you so much for sharing your code with the world!!!
Rated 5 out of 5
This comment was minimized by the moderator on the site
Your code helped me update hundreds of hyperlinks in a blink of an eye. Thank you soo much for you help.
This comment was minimized by the moderator on the site
Thanks a lot, works perfectly fine. Highly appreciated.
This comment was minimized by the moderator on the site
Glad it helps. Any questions, please feel free to contact us. Have a nice day!
This comment was minimized by the moderator on the site
Many thanks for the VBA code to change multiple hyperlink paths at once. Would it be possible to have a version that would go through the different tabs (worksheets) of the xls workbook, as the current version only seems to change the links in the active worksheet? Would be highly appreciated!

Thanks,

Schweppy
This comment was minimized by the moderator on the site
Had a spreadsheet with over 200 items that had hyperlinks that needed to be edited. This just saved me SO MUCH TIME. THANK YOU!!
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations