How do I convert a column of text URLs into active hyperlinks in Excel?

后端 未结 22 2258
刺人心
刺人心 2020-12-07 07:42

I have a column in excel, wherein I have all the website url values. My question is I want to turn the url values to active links. There are about 200 entries in that column

22条回答
  •  长情又很酷
    2020-12-07 08:31

    Thank you Cassiopeia for code. I change his code to work with local addresses and made little changes to his conditions. I removed following conditions:

    1. Change http:/ to file:///
    2. Removed all type of white space conditions
    3. Changed 10k cell range condition to 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
    

提交回复
热议问题