George often inserts hyperlinks into his worksheets. These hyperlinks are to files of various types that reside on his computer system. When he inserts the hyperlinks, the default hyperlink text that Excel inserts is the full path and file name for the file. George would like this hyperlink text, by default, to consist of only the file name, without the full path.
There is one very easy way to accomplish the desired outcome: Simply move the workbook into the same folder with the files to which you want hyperlinks. When you use the Insert Hyperlink dialog box, the filename—without the path—is then used for the link.
If that isn't feasible, then using the Insert Hyperlink dialog box does result in a full path ending up in both the Address field and Text to Display field of the Insert Hyperlink dialog box. There is no way to change this default behavior; you can only edit the default proposed by Excel. This means that you can, on an individual hyperlink basis, edit the Text to Display field in the Insert Hyperlink dialog box so that it shows just the file name, as desired.
Of course, this involves a lot of editing—hence the impetus for George's query. There are a couple of ways around this. The first is to not rely on the Insert Hyperlink dialog box. Instead, construct a formula that inserts the hyperlink using the HYPERLINK function. Let's say, for example, that you have, in cell C2, a path name to the folder containing your files:
C:\Users\allen\Desktop\
Further, you could have a list of filenames in the range D2:D75, such as this:
MyWorkbook.xlsx MyDocument.docx MyPDF.pdf
You could place a formula such as this in cell E2:
=HYPERLINK($C$2 & D2,D2)
Copy the formula down into the range E3:E75, and you'll have your hyperlinks as you desire.
If you already have a bunch of inserted links in the spreadsheet (for example, in column A), you could use a bit larger formula to extract and display just the filename:
=HYPERLINK(A1,SUBSTITUTE(A1,LEFT(A1,FIND(CHAR(1),SUBSTITUTE(A1, "\",CHAR(1),LEN(A1)-LEN(SUBSTITUTE(A1,"\",""))))),""))
You could then hide the column containing the full-path hyperlinks, so you see only the shortened versions that you want.
If you have many hyperlinks that you want to affect, you can use a macro to remove the path from all the existing hyperlinks.
Sub FixHyperlinkDesc()
Dim h As Hyperlink
Dim sRaw As String
Dim iPos As Integer
For Each h In ActiveSheet.Hyperlinks
sRaw = h.TextToDisplay
iPos = Instr(1, sRaw, "\")
While (iPos > 0)
sRaw = Mid(sRaw, iPos + 1, Len(sRaw))
iPos = Instr(1, sRaw, "\")
Wend
If sRaw <> h.TextToDisplay Then
h.TextToDisplay = sRaw
End If
Next h
End Sub
The only thing the macro touches is the display text for each hyperlink, and it deletes everything before the final backslash. The macro won't affect anything that may appear as the result of a HYPERLINK function.
Note:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (13279) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Excel in Microsoft 365.
Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2019 For Dummies today!
Do you use special characters (such as the pound sign) in your worksheet names? If so, you could run into problems ...
Discover MoreNeed to add a hyperlink to a comment or note? It's easy to do by following the steps outlined in this tip.
Discover MoreExcel provides a good number of worksheet functions that can help you pick apart text strings in various ways. In this ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2026-06-14 09:30:52
J. Woolley
The first time I submitted this comment all backslash (\) characters were ignored. I believe this resulted from the "update" of Tips.net. But Allen has corrected the problem, so I will resubmit this comment.
Be aware: If you add the =HYPERLINK(...) formula to a cell that already has a standard Ctrl+K hyperlink, the original hyperlink remains precedent. The new HYPERLINK(...) formula replaces the text in the cell but does not override the original hyperlink because the HYPERLINK function does not create a Hyperlink object. You can read more about HYPERLINK function issues in the PDF file available from My Excel Toolbox here: https://drive.google.com/file/d/1vAXFMwX43N7b-6fEhdY5E0PZRmIQ9zlA/view
The Tip includes the following formula:
=HYPERLINK(A1, SUBSTITUTE(A1, LEFT(A1, FIND(CHAR(1), SUBSTITUTE(A1, "\", CHAR(1), LEN(A1) - LEN(SUBSTITUTE(A1, "\", ""))))), ""))
Here's an alternate version:
=HYPERLINK(A1, RIGHT(A1, LEN(A1) - FIND("|", SUBSTITUTE(A1, "\", "|", LEN(A1) - LEN(SUBSTITUTE(A1, "\", ""))))))
Here's an Excel 2024 version:
=HYPERLINK(A1, TEXTAFTER(A1, "\", -1))
Here's a My Excel Toolbox version:
=HYPERLINK(A1, MID(A1, FindRev("\", A1) + 1, 999))
See https://sites.google.com/view/MyExcelToolbox/
The first four formulas fail if the text in A1 does not include a backslash (\) character, but this RegEx version (currently Excel 365) works correctly:
=HYPERLINK(A1, REGEXREPLACE(A1, ".*\\", ""))
And so does this My Excel Toolbox version:
=HYPERLINK(A1, RegExSubstitute(A1, ".*\\", ""))
And so does this Excel 2024 version:
=HYPERLINK(A1, LET(x, TEXTSPLIT(A1, "\"), INDEX(x, 1, COUNTA(x))))
And so does this My Excel Toolbox version with LET (Excel 2021):
=HYPERLINK(A1, LET(x, SplitText(A1, "\"), INDEX(x, 1, COUNTA(x))))
And so does this legacy version (which might be the best choice):
=HYPERLINK(A1, TRIM(RIGHT(SUBSTITUTE(A1, "\", REPT(" ", LEN(A1))), LEN(A1))))
Or you could modify the first four formulas like this:
=HYPERLINK(A1, IFERROR(..., A1))
Finally, here's an alternate version of the Tip's macro using InStrRev(...):
Sub FixHyperlinkDesc2()
Dim h As Hyperlink, n As Integer
For Each h In ActiveSheet.Hyperlinks
n = InStrRev(h.TextToDisplay, "\")
If n > 0 Then h.TextToDisplay = Mid(h.TextToDisplay, n + 1)
Next h
End Sub
2026-06-14 09:21:53
J. Woolley
THIS IS A TEST. PLEASE IGNORE.
Here is one backslash character: \
Here is one pair of backslash characters: \\
2026-06-13 10:27:09
J. Woolley
@Allen
The text of my comment below does not display backslash characters like this one:
But the text that includes two backslash characters is displayed as one like this pair: \
Can you correct this problem?
2026-06-13 10:20:19
J. Woolley
Be aware: If you add the =HYPERLINK(...) formula to a cell that already has a standard Ctrl+K hyperlink, the original hyperlink remains precedent. The new HYPERLINK(...) formula replaces the text in the cell but does not override the original hyperlink because the HYPERLINK function does not create a Hyperlink object. You can read more about HYPERLINK function issues in the PDF file available from My Excel Toolbox here: https://drive.google.com/file/d/1vAXFMwX43N7b-6fEhdY5E0PZRmIQ9zlA/view
The Tip includes the following formula:
=HYPERLINK(A1, SUBSTITUTE(A1, LEFT(A1, FIND(CHAR(1), SUBSTITUTE(A1, "", CHAR(1), LEN(A1) - LEN(SUBSTITUTE(A1, "", ""))))), ""))
Here's an alternate version:
=HYPERLINK(A1, RIGHT(A1, LEN(A1) - FIND("|", SUBSTITUTE(A1, "", "|", LEN(A1) - LEN(SUBSTITUTE(A1, "", ""))))))
Here's an Excel 2024 version:
=HYPERLINK(A1, TEXTAFTER(A1, "", -1))
Here's a My Excel Toolbox version:
=HYPERLINK(A1, MID(A1, FindRev("", A1) + 1, 999))
See https://sites.google.com/view/MyExcelToolbox/
The first four formulas fail if the text in A1 does not include a backslash () character, but this RegEx version (currently Excel 365) works correctly:
=HYPERLINK(A1, REGEXREPLACE(A1, ".*\", ""))
And so does this My Excel Toolbox version:
=HYPERLINK(A1, RegExSubstitute(A1, ".*\", ""))
And so does this Excel 2024 version:
=HYPERLINK(A1, LET(x, TEXTSPLIT(A1, ""), INDEX(x, 1, COUNTA(x))))
And so does this My Excel Toolbox version with LET (Excel 2021):
=HYPERLINK(A1, LET(x, SplitText(A1, ""), INDEX(x, 1, COUNTA(x))))
And so does this legacy version (which might be the best choice):
=HYPERLINK(A1, TRIM(RIGHT(SUBSTITUTE(A1, "", REPT(" ", LEN(A1))), LEN(A1))))
Or you could modify the first four formulas like this:
=HYPERLINK(A1, IFERROR(..., A1))
Finally, here's an alternate version of the Tip's macro using InStrRev(...):
Sub FixHyperlinkDesc2()
Dim h As Hyperlink, n As Integer
For Each h In ActiveSheet.Hyperlinks
n = InStrRev(h.TextToDisplay, "")
If n > 0 Then h.TextToDisplay = Mid(h.TextToDisplay, n + 1)
Next h
End Sub
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2026 Sharon Parq Associates, Inc.
Comments