我在excel中有一个列,其中我有所有的网站url值。我的问题是我想把url值转换为活动链接。该列中大约有200个条目,所有单元格中都有不同的url。是否有一种方法可以在不编写宏的情况下创建到所有单元格的活动超链接。


当前回答

对于使用Excel 2016登陆这里的任何人,您可以简单地突出显示该列,然后单击样式框中Home ribbon上的超链接选项卡。

编辑:不幸的是,这只更新单元格样式,而不是函数。

其他回答

我发现,如果超链接不包括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

这是我发现的一个方法。我在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中工作。

最简单的方法

突出显示整个列 单击“插入” 点击“超链接” 点击“放入此文档” 单击ok 这是所有

如果不允许添加带有超链接的额外列, 另一种方法是使用外部编辑器将您的超链接包含到=hyperlink(" and "),以获得=hyperlink("originalCellContent")

如果你有notepad++,这是一个你可以用来半自动执行这个操作的配方:

Copy the column of addresses to Notepad++ Keeping ALT-SHIFT pressed, extended your cursor from the top left corner to the bottom left corner, and type =hyperlink(". This adds =hyperlink(" at the beginning of each entry. Open "Replace" menu (Ctrl-H), activate regular expressions (ALT-G), and replace $ (end of line) with "\). This adds a closed quote and a closed parenthesis (which needs to be escaped with \ when regular expressions are activated) at the end of each line. Paste back the data in Excel. In practice, just copy the data and select the first cell of the column where you want the data to end up.

在Mac上,一个非常简单的方法就是在Excel中选择整个电子表格,复制,启动Numbers,粘贴,然后全选,复制,粘贴回Excel中。