我在Excel中有一个创建URL的公式。
https://dev.virtualearth.net/REST/V1/Imagery/Map/Road/33.344098%2C-86.92109/8?mapSize=1500,1500&mapLayer=TrafficFlow&format=png&pushpin=33.344098,-86.92109;64;2&pushpin=33.3326334378716,-86.7889690445497;64;3&pushpin=33.32602,-87.03541;64;4&pushpin=33.69447,-85.85043;64;5&pushpin=33.344098,-86.92109;64;6&pushpin=35.15039,-89.94733;64;7&pushpin=35.096314,-89.804006;64;8&pushpin=35.0512,-89.93951;64;9&pushpin=35.15098,-90.1767;64;10&key=xxxxx
如果我将公式的结果复制/粘贴到浏览器中,则一切正常。
如果我尝试在Excel中创建超链接
HYPERLINK(C23,"Dots on a Map")
我收到一条错误消息,指出错误的数据类型。
需要进行哪些修改才能将单元格C23用作超链接?
答案 0 :(得分:0)
原因是您的url链接包含超过255个字符,而= Hyperlink()函数不允许使用此字符。
如果您拆分链接并连接这些单独的部分(少于255个字符),则可以克服该限制。
使用宏,您可以强制该链接再次可单击。我以Brad Yundt找到的一个为例进行了修改。
Option Explicit
Sub HyperlinkMaker()
'Code assumes column A and B values will be concatenated and used to make a hyperlink
'The hyperlink will be put in column C
Dim i As Long, firstRow As Long, lastRow As Long
Dim sFriendly As String, sHyperlink As String
firstRow = 1 'Put first hyperlink on this row
With ActiveSheet
lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row 'Look at last cell in column A with data
For i = firstRow To lastRow
sHyperlink = .Cells(i, "B").Value & .Cells(i, "B").Value & .Cells(i, "B").Value 'Build the hyperlink
sFriendly = .Cells(i, "A").Value 'Display the "Friendly" value instead of full hyperlink
If sHyperlink <> "" Then .Hyperlinks.Add anchor:=.Cells(5, 1), Address:=sHyperlink, TextToDisplay:=sFriendly 'Output is set to cell(1,5), i.e A5
Next
End With
End Sub
在我的示例中,我将您的链接分为3个单元格(B1
,B2
和B3
),并在A1
中命名。输出结果将在A5
中。