Excel 单元格

分两列 (B列存放姓名, C列存放链接)

列如:

1309032022李汉超http://www.cnblogs.com/Vpygamalion/
1413042001叶月欣http://www.cnblogs.com/yeyuexin/
1413042002纪杨阳http://www.cnblogs.com/yangyangji/

等等

要求在B列建立C列指示的链接 (自动建立)

VBA 脚本如下:


Public Sub addURL()

 Dim BLeft As String
Dim CRight As String
Dim Line As Integer For Line = 2 To 58 '分别标示起始和结束行,实际使用时 调整参数 2和 58, 也可以作为函数参数 BLeft = "B" + CStr(Line)
CRight = "C" + CStr(Line) Range(BLeft).Select
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:=Range(CRight).Value, TextToDisplay:=Range(BLeft).Value Range(CRight).Clear ' 将C列清除
Next Line End Sub

执行脚本后,如下:

1309032022李汉超
1413042001叶月欣
1413042002纪杨阳

等等

05-19 17:26