Excel 365 Convert Hyperlinks
⚠️Warning:
When saving the Excel file that contains a macro, you will be prompted to save it as an .xlsm (Macro-Enabled Workbook).
What this macro does
ConvertFormulaToHyperlink converts selected Excel cells that contain a HYPERLINK(<cell>) formula into clean, permanent, clickable hyperlinks.
In detail, it:
•Only runs on the worksheet named processed (all lowercase)
○If you run it on any other sheet, it stops and shows a warning.
•Works only on the cells you select
•Finds cells containing a HYPERLINK(<cell>) formula where <cell> contains the original URL or email
•Cleans the link text
○Removes non-breaking spaces
○Trims spaces from the start and end
•Handles email addresses correctly
○If the value looks like an email (name@domain.com), it creates a mailto: link
•Recreates the hyperlink
○Deletes any existing hyperlink
○Adds a fresh, clean hyperlink using the cleaned value
•Removes the formula
○Leaves plain text behind, but keeps the hyperlink working
•Shows a confirmation message
○Tells you how many hyperlinks (cells) were converted to text
👉 End result: no formulas, no hidden spaces, just clean clickable links.
How to run the macro
1.Open the workbook
2.Press ALT + F11 to open the VBA Editor
3.Go to Insert → Module
4.Paste the macro code into the module window
5.Close the VBA Editor
6.In Excel:
•Go to the processed sheet
•Select the cells you want to convert
7.Press ALT + F8
8.Choose ConvertFormulaToHyperlink
9.Click Run
You’ll see a message confirming how many hyperlinks were converted.
When to use this macro
•You want to remove formulas but keep links clickable
•You’ve copied data with hidden spaces that break links
•You need email addresses to open mail clients properly
•You want a clean, final dataset
👉 The macro code is shown below: Copy it and paste it into the VBA Editor.
ℹ️ The macro starts with a Sub and ends with a End Sub
Sub ConvertFormulaToHyperlink()
Dim c As Range
Dim convertedCount As Long
Dim cleanLink As String
Dim linkAddress As String
' Ensure macro only runs on the correct sheet
If ActiveSheet.Name <> "processed" Then
MsgBox "This macro can only be run on the sheet named 'processed'.", _
vbExclamation, "Incorrect Sheet"
Exit Sub
End If
convertedCount = 0
For Each c In Selection
If c.HasFormula Then
If InStr(1, c.Formula, "HYPERLINK", vbTextCompare) > 0 Then
' Remove non-breaking spaces then trim
cleanLink = Replace(c.Value, Chr(160), "")
cleanLink = Trim(cleanLink)
' 🔑 Handle email addresses correctly
If cleanLink Like "*@*.*" Then
linkAddress = "mailto:" & cleanLink
Else
linkAddress = cleanLink
End If
' Remove any existing hyperlink first
If c.Hyperlinks.Count > 0 Then c.Hyperlinks.Delete
' Add cleaned hyperlink
c.Hyperlinks.Add _
Anchor:=c, _
Address:=linkAddress, _
TextToDisplay:=cleanLink
' Convert to plain text
c.Value = cleanLink
convertedCount = convertedCount + 1
End If
End If
Next c
MsgBox convertedCount & " hyperlink(s) converted successfully.", _
vbInformation, "Conversion Complete"
End Sub
Topic last reviewed: 19/01/26