我在excel中有一个列,其中我有所有的网站url值。我的问题是我想把url值转换为活动链接。该列中大约有200个条目,所有单元格中都有不同的url。是否有一种方法可以在不编写宏的情况下创建到所有单元格的活动超链接。
当前回答
我有一个数字列表,馈送到url的我想热链接。 例如,我有一个列A的问题编号(即,2595692,135171),我想把这些问题编号转换为热链接,并只显示问题编号。
因此,我建立了一个指向列a的纯文本超链接,并将其复制下来用于我所有的问题编号:
=“=超链接(”&“”“http”&“”&“”/stackoverflow.com/questions/“&”&“”&A1&“)”
然后我复制粘贴值这一列的文本超链接到另一列。
你最终会得到如下所示的一列文本:
=超链接(“http”&“:”&“//stackoverflow.com/questions/2595692”,2595692)
然后我选择这些粘贴的项目,并运行F2Entry宏如下:
Sub F2Enter()
Dim cell As Range
Application.Calculation = xlCalculationManual
For Each cell In Selection
cell.Activate
cell = Trim(cell)
Next cell
Application.Calculation = xlCalculationAutomatic
EndSub
然后我删除了文本输入列和列A。
我最终得到了一列热链接的问题数字:
2595692
135171
etc.
干杯
其他回答
这是我发现的一个方法。我在Mac上使用Excel 2011。 如果列B有你想要超链接的文本值,把这个公式放在单元格C1(或D1或其他,只要它是一个空闲列):=HYPERLINK(B1,B1) 这将插入一个超链接,链接文本为位置,链接文本为“友好名称”。如果您有另一列,每个链接都有一个友好的名称,您也可以使用它。 然后,如果不想看到文本列,可以隐藏它。
如果你有一个id列表,并且url都是http://website.com/folder/ID,比如:
A1 | B1
101 | http://website.com/folder/101
102 | http://website.com/folder/102
103 | http://website.com/folder/103
104 | http://website.com/folder/104
你可以使用=HYPERLINK("http://website.com/folder/"&A1,A1)这样的东西,你不需要url列表。这就是我的情况,而且效果很好。
根据这篇文章:http://excelhints.com/2007/06/12/hyperlink-formula-in-excel/,这个方法也可以在Excel 2007中工作。
我发现,如果超链接不包括http://,因为它们链接到本地位置,那么这里的方法都不起作用。
我还想让脚本万无一失,因为用户无法自己维护它,而我也无法使用。
它只会在选定范围内包含点且没有空格的单元格上运行。它最多只能运行1万个细胞。
Sub HyperAdd()
Dim CellsWithSpaces As String
'Converts each text hyperlink selected into a working hyperlink
Application.ScreenUpdating = False
Dim NotPresent As Integer
NotPresent = 0
For Each xCell In Selection
xCell.Formula = Trim(xCell.Formula)
If xCell.Formula = "" Or InStr(xCell.Formula, ".") = NotPresent Then
'Do nothing if the cell is blank or contains no dots
Else
If InStr(xCell.Formula, " ") <> 0 Then
CellsWithSpaces = CellsWithSpaces & ", " & Replace(xCell.Address, "$", "")
GoTo Nextxcell
End If
If InStr(xCell.Formula, "http") <> 0 Then
Hyperstring = Trim(xCell.Formula)
Else
Hyperstring = "http://" & Trim(xCell.Formula)
End If
ActiveSheet.Hyperlinks.Add Anchor:=xCell, Address:=Hyperstring
End If
i = i + 1
If i = 10000 Then Exit Sub
Nextxcell:
Next xCell
If Not CellsWithSpaces = "" Then
MsgBox ("Please remove spaces from the following cells:" & CellsWithSpaces)
End If
Application.ScreenUpdating = True
End Sub
谢谢仙后座的代码。我更改了他的代码,使其与本地地址一起工作,并对他的条件做了一些更改。我删除了以下条件:
将http:/修改为file:/// 删除了所有类型的空白条件 改变10k单元格范围条件为100k
Sub HyperAddForLocalLinks()
Dim CellsWithSpaces As String
'Converts each text hyperlink selected into a working hyperlink
Application.ScreenUpdating = False
Dim NotPresent As Integer
NotPresent = 0
For Each xCell In Selection
xCell.Formula = Trim(xCell.Formula)
If InStr(xCell.Formula, "file:///") <> 0 Then
Hyperstring = Trim(xCell.Formula)
Else
Hyperstring = "file:///" & Trim(xCell.Formula)
End If
ActiveSheet.Hyperlinks.Add Anchor:=xCell, Address:=Hyperstring
i = i + 1
If i = 100000 Then Exit Sub
Nextxcell:
Next xCell
Application.ScreenUpdating = True
End Sub
这个方法适用于我使用超链接函数:
=HYPERLINK("http://"&B10,B10)
其中B10是包含URL文本版本的单元格(在本例中)。
最简单的方法
突出显示整个列 单击“插入” 点击“超链接” 点击“放入此文档” 单击ok 这是所有
推荐文章
- 我如何用javascript编程点击链接?
- 为什么我在我的Excel插件中得到“无法在证书存储中找到清单签名证书”?
- c# XML文档网站链接
- 我如何在NSAttributedString中创建一个可点击的链接?
- 链接重新加载当前页面
- 如何创建在移动设备上呼叫电话号码的超链接?
- 没有href属性的锚标记安全吗?
- 我怎样才能得到任何URL或网页的谷歌缓存年龄?
- 在一个UILabel的NSAttributedString中创建可点击的“链接”?
- jQuery禁用链接
- 在Chrome中打印时需要删除href值
- 如何将一列文本url转换为Excel中的活动超链接?
- 如何将地址转换为谷歌地图链接(非地图)
- 如何使一个HTML回链接?
- 如何使按钮看起来像一个链接?