excel 2010编辑多个超链接VBA,宏 [英] excel 2010 edit multiple hyperlinks VBA, macro

查看:271
本文介绍了excel 2010编辑多个超链接VBA,宏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

...一个简单的问题(对某些人来说:)

...a simple question (for some :)

目标是更改一系列单元格中的部分超链接

the goal is to change a part of hyperlinks in a range of cells


  • 表'进度'

  • 范围'd9:d38'

现在超链接(rc001在D9中; rc002在D10中,依此类推)

hyperlinks now (rc001 is in D9; rc002 in D10 and so on)

.. \。 。\..\..\..\..\..\AppData\Roaming\Microsoft\Excel\VNHS2_Reconciliation_report_RC001.xlsx

超链接

VNHS2_Reconciliation_report_RC001.xlsx (rc001 increasing by 1 up to 030)

任何人?非常请:)

推荐答案

这是一个基本字符串替换的简单循环。我定义了一个基本的超链接地址:

This is a simple loop with basic string replacement. I define a base Hyperlink address:

Const sFile As String = "..\..\..\..\..\..\..\AppData\Roaming\Microsoft\Excel\VNHS2_Reconciliation_report_RC000.xlsx"

然后使用替换方法将 000 部分更改为<$每个单元格的c $ c> 001 , 002 等。

And then use the Replace method to change the 000 part to 001, 002, etc., for each cell.

Sub Foo()
Const sFile As String = "..\..\..\..\..\..\..\AppData\Roaming\Microsoft\Excel\VNHS2_Reconciliation_report_RC000.xlsx"
Dim rngLinks As Range: Set rngLinks = Range("D9:D38")
Dim cl As Range
Dim i As Integer

For Each cl In rngLinks
    i = i + 1
    cl.Hyperlinks.Add cl, Replace(sFile, "000", Format(i, "00#"))

Next



End Sub

这篇关于excel 2010编辑多个超链接VBA,宏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆