我在excel中有一个列,其中我有所有的网站url值。我的问题是我想把url值转换为活动链接。该列中大约有200个条目,所有单元格中都有不同的url。是否有一种方法可以在不编写宏的情况下创建到所有单元格的活动超链接。
当前回答
将url放入HTML表格,将HTML页面加载到浏览器中,复制该页面的内容,粘贴到Excel中。此时,url被保留为活动链接。
解决方案是由(Jim Gordon Mac MVP)在http://answers.microsoft.com/en-us/mac/forum/macoffice2008-macexcel/how-to-copy-and-paste-to-mac-excel-2008-a-list-of/c5fa2890-acf5-461d-adb5-32480855e11e上提出的[http://answers.microsoft.com/en-us/profile/75a2b744-a259-49bb-8eb1-7db61dae9e78]
我发现这很有效。
我有这些url:
https://twitter.com/keeseter/status/578350771235872768/photo/1 https://instagram.com/p/ys5ASPCDEV/ https://igcdn-photos-g-a.akamaihd.net/hphotos-ak-xfa1/t51.2885-15/10881854_329617847240910_1814142151_n.jpg https://twitter.com/ranadotson/status/539485028712189952/photo/1 https://instagram.com/p/0OgdvyxMhW/ https://instagram.com/p/1nynTiiLSb/
我把它们放入一个HTML文件(links.html),就像这样:
<table>
<tr><td><a href="https://twitter.com/keeseter/status/578350771235872768/photo/1">https://twitter.com/keeseter/status/578350771235872768/photo/1</a></td></tr>
<tr><td><a href="https://instagram.com/p/ys5ASPCDEV/">https://instagram.com/p/ys5ASPCDEV/</a></td></tr>
<tr><td><a href="https://igcdn-photos-g-a.akamaihd.net/hphotos-ak-xfa1/t51.2885-15/10881854_329617847240910_1814142151_n.jpg">https://igcdn-photos-g-a.akamaihd.net/hphotos-ak-xfa1/t51.2885-15/10881854_329617847240910_1814142151_n.jpg</a></td></tr>
<tr><td><a href="https://twitter.com/ranadotson/status/539485028712189952/photo/1">https://twitter.com/ranadotson/status/539485028712189952/photo/1</a></td></tr>
<tr><td><a href="https://instagram.com/p/0OgdvyxMhW/">https://instagram.com/p/0OgdvyxMhW/</a></td></tr>
</table>
然后我将links.html加载到浏览器中,复制粘贴到Excel中,链接就激活了。
其他回答
创建宏如下所示:
在microsoftexcel的“工具”菜单上指向“宏”,然后单击“Visual Basic编辑器”。 在“插入”菜单上,单击“模块”。 将此代码复制并粘贴到模块的代码窗口中。 它会自动命名为HyperAdd。
Sub HyperAdd()
'Converts each text hyperlink selected into a working hyperlink
For Each xCell In Selection
ActiveSheet.Hyperlinks.Add Anchor:=xCell, Address:=xCell.Formula
Next xCell
End Sub
粘贴完宏后,单击“文件”菜单上的“关闭并返回到microsoftexcel”。
然后选择所需的单元格,单击宏,然后单击运行。
说明不要选择整个列!只选择单元格,你希望被改变为可点击的链接,否则你将结束在一个永无休止的循环,并必须重新启动Excel! 完成了!
这个方法适用于我使用超链接函数:
=HYPERLINK("http://"&B10,B10)
其中B10是包含URL文本版本的单元格(在本例中)。
我发现,如果超链接不包括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
如果你复制文本内容到一个新的列,并使用:
=HYPERLINK("http://"&B10,B10)
在你原来的专栏上。然后使用$的列,使它看起来像这样:
=HYPERLINK("http://"&$B10,$B10)
这是我在Windows 7上使用Excel 2010的唯一方法。你可以把这个公式抄下来。
您可以插入公式=HYPERLINK(<your_cell>,<your_cell>)到相邻的单元格,并将其一直拖到底部。这将为您提供一个包含所有链接的列。现在,您可以通过单击标题,右键单击并选择Hide来选择原始列。
推荐文章
- 为什么我在我的Excel插件中得到“无法在证书存储中找到清单签名证书”?
- c# XML文档网站链接
- 我如何在NSAttributedString中创建一个可点击的链接?
- 链接重新加载当前页面
- 如何创建在移动设备上呼叫电话号码的超链接?
- 没有href属性的锚标记安全吗?
- 我怎样才能得到任何URL或网页的谷歌缓存年龄?
- 在一个UILabel的NSAttributedString中创建可点击的“链接”?
- jQuery禁用链接
- 在Chrome中打印时需要删除href值
- 如何将一列文本url转换为Excel中的活动超链接?
- 如何将地址转换为谷歌地图链接(非地图)
- 如何使一个HTML回链接?
- 如何使按钮看起来像一个链接?
- 如何强制链接从iframe被打开在父窗口