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


当前回答

这个方法适用于我使用超链接函数:

=HYPERLINK("http://"&B10,B10)

其中B10是包含URL文本版本的单元格(在本例中)。

其他回答

如果你复制文本内容到一个新的列,并使用:

=HYPERLINK("http://"&B10,B10) 

在你原来的专栏上。然后使用$的列,使它看起来像这样:

=HYPERLINK("http://"&$B10,$B10)

这是我在Windows 7上使用Excel 2010的唯一方法。你可以把这个公式抄下来。

Excel 2010中最简单的方法: 选择带有URL文本的列,然后从“主页”选项卡选择“超链接样式”。 列中的所有url现在都是超链接。

同时双击URL文本末尾的每个单元格,并添加一个空白或直接输入也会产生一个超链接。类似于您必须在MS Outlook电子邮件中创建URL链接的方式。

最简单的方法

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

谢谢仙后座的代码。我更改了他的代码,使其与本地地址一起工作,并对他的条件做了一些更改。我删除了以下条件:

将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

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