【发布时间】:2016-06-07 10:06:15
【问题描述】:
我制作了一个宏,可以将超链接从一列复制到另一列。
宏工作得很好,但是超链接在它们中间包含“#”所以我们说:
https://website.com/nu#somethingsomething
这使得宏复制只是它的第一部分,即:
https://website.com/nu
有什么想法可以让 Excel 忽略“#”(如果可能的话)并复制超链接的整个值?
VBA 代码:
Sub MilestonesHyperlink()
For i = 2 To 62 'Number of rows
If Range("B" & i).Value <> "" And Range("A" & i).Value <> "" Then 'Copy from column B to A
Dim newLink As String
If Range("B" & i).Hyperlinks.Count = 1 Then
newLink = Range("B" & i).Hyperlinks(1).Address
Range("A" & i).Hyperlinks.Add anchor:=Range("A" & i), Address:=Range("A" & i)
Range("A" & i).Hyperlinks(1).Address = newLink
End If
End If
Next i
End Sub
【问题讨论】: