如何在Excel的CONCATENATE函数中使用超过255个字符?我实际上也在EXCEL的HYPERLINK函数中使用CONCATENATE函数.示例如下所示:
=HYPERLINK(CONCATENATE("http://www.google/com/morethan255charsmorethan255charsmorethan255charsmorethan255charsmorethan255charsmorethan255charsmorethan255charsmorethan255charsmorethan255charsmorethan255chars","morethan255chars morethan255charsmorethan255charsmorethan255charsmorethan25"),"link");
Run Code Online (Sandbox Code Playgroud)
更新:这不是CONCATENATE函数的问题,而是HYPERLINK函数的第一个参数的问题.直接/间接使用长度超过255个字符的字符串(例如:= HYPERLINK(K204,"link"),其中K204包含256个字符的长度链接)HYPERLINK功能失败
我意识到我可以使用URL缩短器,但我正在为大量的链接执行此操作,这需要大量手动使用URL缩短器.
对于那些遇到这个问题的人以及那些认为这个问题可能太旧而无法谈论的支持人员来说,快速更新:
Excel for Microsoft 365 MSO(版本 2203 内部版本 16.0.15028.20102)仍然存在此错误。
当您想要参数化的典型 URL(Excel 中的常见用法)轻松超过 255 个时,这有点不可原谅,并且大多数互联网软件的默认限制为 1024 个字符……许多甚至允许通过配置超过该限制。
这个问题已经存在了12年了,一直没有得到解决。
更新:由于 Karls 的评论,我重新审视了我的答案,发现 Excel 2007 似乎不再允许用户定义函数设置超链接(非常明智,请参阅代码中我自己的评论)。因此,原始代码(行下方)在更新版本的 Excel 中不起作用(我尚未测试 Excel 2010,但我假设结果是相同的)。由于历史原因,我不会删除旧代码(编辑可能会有不同的想法——请随意编辑/删除相应的代码)。
所以剩下的就是以编程方式设置长超链接,例如
Sub insertVeryLongHyperlink()
Dim curCell As Range
Dim longHyperlink As String
Set curCell = Range("A1") ' or use any cell-reference
longHyperlink = "http://www.veryLongURL.com/abcde" ' Or a Cell reference like [C1]
curCell.Hyperlinks.Add Anchor:=curCell, _
Address:=longHyperlink, _
SubAddress:="", _
ScreenTip:=" - Click here to follow the hyperlink", _
TextToDisplay:="Long Hyperlink"
End Sub
Run Code Online (Sandbox Code Playgroud)
以下内容在 Excel 2010 中不再适用;看我上面的评论
“从 Word 复制超链接并粘贴到 Excel 中”让我思考。显然,限制在于内置的超链接功能和对话框窗口“编辑超链接”。另一方面,应该并且实际上可以通过 VBA 设置更长的超链接。
此代码不再适用于 Excel 2010
Function myHyperlink(cell As Range, _
hyperlinkAddress As String, _
Optional TextToDisplay As Variant, _
Optional ScreenTip As Variant)
' Inserts a Hyperlink
' at the position cell (this should be the position where the UDF is used,
' since the return value of the UDF is = TextToDisplay)
' with the hyperlinkAddress
' optional TextToDisplay
' optional ScreenTip
' #######################################
' Warning Warning Warning Warning Warning
' #######################################
' 1) Since it is really bad practice to have a function perform procedural
' tasks, you should not do this.
' 2) You have no garantee, the link is updated when the value hyperlinkAddress changes
' USE AT YOUR ONE RISK AND ONLY IN CASE OF EMERGENCIES :-)
' If more than one cell is selected as target range,
' use the top left cell
Set cell = cell.Resize(1, 1)
If IsMissing(TextToDisplay) Then
TextToDisplay = hyperlinkAddress
End If
If IsMissing(ScreenTip) Then
ScreenTip = hyperlinkAddress & " - Click here to follow the hyperlink"
End If
cell.Hyperlinks.Add Anchor:=ActiveCell, _
Address:=hyperlinkAddress, _
SubAddress:="", _
ScreenTip:=ScreenTip, _
TextToDisplay:=TextToDisplay
' There doesn't seem to be another way to set TextToDisplay
myHyperlink = TextToDisplay
End Function
Run Code Online (Sandbox Code Playgroud)
用作普通 Excel 函数,但请确保将当前单元格添加为第一个参数(即,将以下公式插入到单元格 A1 中)
=myHyperlink(A1,B1)
=myHyperlink(A1,B1,"TextToDisplay", "ScreenTip")
Run Code Online (Sandbox Code Playgroud)
您既不能将公式拉下来,也不能将其复制到另一个单元格。如果这样做,则必须重新计算公式(无论是 ALT-CTRL-F9 还是 ALT-CTRL-SHIFT-F9,因为强制重新计算似乎都起作用),因此进入每个单元格,按 F2 激活它并按 Return 完成。
我希望我没有帮助您搞砸太多 Excel 工作簿。
编写一个显式启动的 VBA 可能更安全,该 VBA 会迭代列表并写入超链接。这样它们就可以重复使用并且没有任何功能。
问候安德烈亚斯
| 归档时间: |
|
| 查看次数: |
29718 次 |
| 最近记录: |