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


当前回答

使用Windows上的Excel 2007,我发现这些步骤最简单;

选择具有非活动url的单元格 复制 粘贴为超链接

其他回答

对于比较短的列表来说非常简单:

双击url所在的方框 输入

你有你的链接;)

有一个非常简单的方法。创建一个超链接,然后使用格式绘制器复制格式。它将为每个项目创建一个超链接。

我很惊讶Excel没有自动做这个,所以这是我的解决方案,我希望对其他人有用,

将整个列复制到剪贴板 在Chrome或Firefox上打开这个

data:text/html,<button onclick=“document.write(document.body.querySelector('textarea').value.split('\n').map(x => '<a href=</a>\'' + x + '\'>' + x + '').join(''))<br>”>Linkify</button><br><textarea></textarea>

将该栏粘贴到刚刚在浏览器上打开的页面上,然后按“链接”键 将结果从选项卡复制到Excel的列中

代替第二步,您可以使用下面的页面,首先,单击“运行代码片段”,然后将列粘贴在上面 <按钮onclick = " document . write (document.body.querySelector(文本区域).value.split(“\ n”)。地图(x = > < a href = \”+ x + '\'>' + x + < / >) . join(“< br >”))按钮“>其内< / > < br > < textarea > < / >文本区域

如果不允许添加带有超链接的额外列, 另一种方法是使用外部编辑器将您的超链接包含到=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.

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

将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