Home > Formulas > Lookup > Hyperlink Excel Hyperlinks and Hyperlink FunctionCreate hyperlinks by dragging and dropping, or with the HYPERLINK function. Remove hyperlinks manually, or with a macro. Hyperlink security warnings. Make a clickable table of contents in an Excel workbook |
Create Excel HyperlinksIn a Microsoft Excel worksheet, you can create a hyperlink in any cell. Then, click that hyperlink to go to the specified location. Here are four ways create a hyperlink in an Excel spreadsheet -- click a link to go to those instructions, below:
|
Type a Website URLIf you type a valid website address in a cell, Excel should automatically create a hyperlink, when you press Enter. For example,
The text changes to a hyperlink, and you can click the link to go to the Contextures website. Tip: If you want to stop hyperlinks from being automatically created in Excel, follow the instructions here. |
a) Text in CellIf the selected cell contains text, that text will appear in the Text to Display box.
b) Empty CellIf the selected cell is empty, the sheet name, and cell A1 will appear in the Text to Display box.
|
c) Number in CellIf the selected cell contains a real number, you will not be able to edit the Text to Display box. The box contents are dimmed out, and it shows this message: < < Selection in Document > >
If you want to edit the Text to Display:
OR
![]() |
d) "Text" Number in CellIf the selected cell contains a "text" number (formatted as text, or starting with an apostrophe), that text number will appear in the Text to Display box.
Add a Screen Tip (Optional)When you point to a cell that contains a hyperlink, its Screen Tip appears. You can enter your own text for the Screen Tip, or leave this setting empty. NOTE: If you leave the Screen Tip empty, the full hyperlink address will appear in the Screen Tip. To add your own text for the Screen Tip:
|
Choose Link TypeThere are four options in the "Links To" panel, in the Insert Hyperlink window:
At the left side of the Insert Hyperlink window, click the link type that you need. Existing File or Web PageUse this option, if you want to make it easy for people to open another Excel file, or go to a web page, for more information.
|
Video: Create Hyperlinks with Drag and DropIf you're creating hyperlinks within an Excel file, the quickest and easiest method is to use drag and drop. For example, you could create a table of contents sheet (TOC), in a workbook, with links to other sheet. To see a quick overview of how you can create a hyperlink by drag and drop, you can watch this short video. The written instructions are below the video. If you have trouble dragging to a different sheet, drag to a nearby blank cell, then cut and paste onto the other sheet. This animated gif shows those steps. |
Hyperlink Security WarningIn some versions of Excel, you might see a security warning (shown below), when you click on a worksheet hyperlink. Every morning, I see these messages after clicking on worksheet links that I know are safe, such as the Canadian government's weather forecast, and pages on my own website! Warning Message TextFor example, the screen shot below shows the message I see after clicking a link to the Microsoft site. Here is the text shown in the warning message:
Cannot Turn Warnings OffThese warnings are part of Microsoft's security system, and there's no setting in Excel where you can turn those safety warnings off. Also, there's no list where you can "whitelist" specific websites, to assure Excel that they're safe. No matter how many times you've previously clicked a link, you'll get the warning message. Click one of the buttons, based on your trust of the destination website:
|
Video: Excel HYPERLINK FunctionThis video shows a quick overview of how you can create clickable hyperlinks with the Excel HYPERLINK function. There are written steps and examples below the video. |
HYPERLINK SyntaxThe HYPERLINK function has two arguments in its syntax:
Character LimitFor the HYPERLINK function, there is a character limit when you build the link_location string. If you exceed the limit, the formula result will be a #VALUE error.
|
HYPERLINK Function ExamplesSee the following sections for HYPERLINK function examples: 1) HYPERLINK Example - WebsiteIn the screen shot below, there are company names in column A, and a URL for each company's website in column B.
In the HYPERLINK formula, both arguments will be used:
To create a hyperlink for each address, in column C, follow these steps:
The formula result shows the name from cell A2. If you click the link, it goes to the company website URL from cell B2.
|
2) HYPERLINK Example - EmailThe HYPERLINK function can also create a link that opens an email message. In the example shown below, there are email addresses in column A, and the HYPERLINK formula will be added in column B. To create an email link, the Location_Link text string needs to start with "mailto:"
Email Message SettingsFor email hyperlinks, that start with "mailto:" you can include extra information in the link_location argument. For example, the following formula includes text for the email subject line, and for the email body
Here's what the email looks like, if you click the HYPERLINK formula link.
|
MailTo - Subject and Body TextTo include email subject and body text in the HYPERLINK formula, the link needs to follow the internet standards, using the syntax described in the RFC Editor, in the mailto URL scheme documentation.
Add a Line BreakThere are email URL examples in the RFC Editor, mailto URL scheme documentation, section 6. You can adapt those examples, and use them to build link_location strings for the Excel HYPERLINK function. I found those examples, when I wanted to put a line break in a message body. Some of the examples show the special code that you can use, to indicate a line break: %0D%0A For example, the following formula combines gets the email address from cell B5, then adds a subject line. In the message body, there are two lines of text, separated by a line break.
|
3) HYPERLINK Example - Excel FileWith a HYPERLINK formula, you can link to a location in the current Excel workbook, or to another Excel file. This video shows the steps, and there are written steps below the video. TIP: To follow along with this video, you can download the Open Excel Files with Hyperlinks workbook. |
3) Type a Range NameFor a link to a workbook-level named range in the same workbook, just use the range name as the link location.
4) Next Empty CellGo to the empty cell at the end of a worksheet list, or a named table. 5) Worksheet ListIn cell B1, the formula finds the first empty cell after the worksheet list in column A:
To find the empty row number, add the count of items in column A, plus the row number for the starting cell. 6) Named TableIn cell E1, the formula finds the first empty cell after the named table in column D:
|
Remove HyperlinksBelow are the instructions for two methods of removing hyperlinks and a macro to remove hyperlinks Manually Remove HyperlinksIn Excel 2010 or later:In Excel 2010, you can quickly remove hyperlinks from selected cells. (Thanks to Sam for this tip.)
To see the steps, watch this Excel Quick Tips video. |
In Excel 2007 and earlier versions:To remove hyperlinks from a group of cells, you can copy and paste the cells as values. To see the steps, watch this Excel Quick Tips video. |
Point to HyperlinkFollow these steps to make the pointing hand appear anywhere in a hyperlink cell, and see how to select a hyperlinked cell, without following the link. Show the Pointing HandIf a wide cell contains a short hyperlink, the pointing hand will only appear when it's over the text, not in the empty space. To fix that:
Select a Hyperlink CellIf you need to select a hyperlink cell, perhaps to edit the text, without following the link:
|
Add Hyperlink in Threaded CommentThanks to Christian Back (LinkedIn profile), who alerted me to this helful new feature in threaded comments. In Excel 365, you can add clickable hyperlinks in Excel's threaded comments. That makes it easy to provide links to related information, without filling the worksheet cells with hyperlinks. If you're not familiar with threaded comments, see the basic steps on my Threaded Comments page. You can also download the Comment Hyperlinks sample file, in the download section, at the end of this page. Follow Hyperlink in CommentTo use a threaded comment hyperlink, follow these steps:
See Hyperlinks in Comments PaneIn some cases, the Ctrl + click doesn't work, when I use the hyperlink in the cell's pop-up threaded comments. If that happens in your version of Excel too, you can open the Comments Taskpane, and then Ctrl + Click the hyperlinks there. For details on opening the taskpane, and adjusting it, go to the Threaded Comments macros page.
|
Create Sheet List With Links (Macro)The following code will create a Table of Contents in an Excel file, with a list of all the visible worksheets, and a hyperlink to cell A1 on each sheet. You can get this code in a sample file -- look for download #3 in the list below Tip: On each worksheet, put a hyperlink back to the Table of Contents sheet. Sub CreateTOC() Dim wsA As Worksheet Dim ws As Worksheet Dim wsTOC As Worksheet Dim lRow As Long Dim rngList As Range Dim lCalc As Long Dim strTOC As String Dim strCell As String lCalc = Application.Calculation On Error GoTo errHandler Application.EnableEvents = False Application.ScreenUpdating = False Application.Calculation = xlCalculationManual strTOC = "TOC" strCell = "A1" Set wsA = ActiveSheet On Error Resume Next Set wsTOC = Sheets(strTOC) On Error GoTo errHandler If wsTOC Is Nothing Then Set wsTOC = Sheets.Add(Before:=Sheets(1)) wsTOC.Name = strTOC Else wsTOC.Cells.Clear End If With wsTOC .Range("B1").Value = "Sheet Name" lRow = 2 For Each ws In ActiveWorkbook.Worksheets If ws.Visible = xlSheetVisible _ And ws.Name <> strTOC Then .Cells(lRow, 2).Value = ws.Name .Hyperlinks.Add _ Anchor:=.Cells(lRow, 2), _ Address:="", _ SubAddress:="'" & ws.Name _ & "'!" & strCell, _ ScreenTip:=ws.Name, _ TextToDisplay:=ws.Name lRow = lRow + 1 End If Next ws Set rngList = .Cells(1, 2).CurrentRegion rngList.EntireColumn.AutoFit .Rows(1).Font.Bold = True End With Application.ScreenUpdating = True wsTOC.Activate wsTOC.Cells(1, 2).Activate exitHandler: Application.EnableEvents = True Application.ScreenUpdating = True Application.Calculation = lCalc Set rngList = Nothing Set wsTOC = Nothing Set ws = Nothing Set wsA = Nothing Exit Sub errHandler: MsgBox "Could not create list" Resume exitHandler End Sub |
Clickable Hyperlinks for Export to PDFIn some versions of Excel, you might have a problem with your hyperlinks, when you create a PDF file from your Excel workbook. Links Not Clickable in PDFIn the PDF file, some of your hyperlinks might not be clickable, if:
For example, the PDF hyperlink won't work if the friendly name is "Click for info", and the link location is google.com Avoid the ProblemTo avoid this problem, either:
|
Create Fake Hyperlinks in Pivot TableTo create fake hyperlinks in a pivot table, you can use a few lines of code on the worksheet's module. Copy this code, and change the field name, to match the name in your pivot table. You can also get this code in a sample file -- look for download #2 in the list below Two Fields: There is also a sample file, with slightly different code, for a pivot table with TWO fake hyperlink pivot fields. The download link for this is also in download #2 in the list below Notes
|
Clickable Hyperlink Macro CodeCopy the code below, and paste it onto the worksheet code module, on the sheet where your pivot table is located. To get to that code module, right-click the sheet tab, then click View Code. Private Sub Worksheet_SelectionChange _ (ByVal Target As Range) Dim selPF As PivotField Dim strField As String Dim strAdd As String Dim myVal As String strField = "Site" On Error Resume Next Set selPF = Target.PivotField If Not selPF Is Nothing And _ selPF.Name = strField Then myVal = Target.Value If InStr(1, myVal, "@") > 0 Then strAdd = "mailto:" End If ThisWorkbook.FollowHyperlink _ Address:=strAdd & myVal, _ NewWindow:=True End If End Sub |
Video: Create Function to Extract Hyperlink AddressThere's no built in function to extract the URL or email address from a hyperlink. You can create your own Excel function -- a User Defined Function (UDF) -- to extract the address. To see a quick overview of how you can create your own UDF to extract a hyperlink location, you can watch this short video. The written instructions are below the video. NOTE: Hyperlinks that you create with the HYPERLINK function are not recognized as worksheet Hyperlinks. |
Hide Sheets After HyperlinkIn a large workbook, you can use hyperlinks as a table of contents, to quickly go to a specific sheet. Then, on each worksheet, have another hyperlink, to go back to the table of contents. To keep things looking tidy, you can use code that hides each sheet, after you click a hyperlink on that sheet. Thanks to Jim Williams for suggesting this technique. The following code is stored on the ThisWorkbook module, and it runs when a hyperlink is clicked on an worksheet in that workbook. You can also get this code in a sample file -- look for download #4 in the list below Private Sub Workbook_SheetFollowHyperlink _ (ByVal Sh As Object, ByVal Target As Hyperlink) 'shows hidden target sheet and 'hides sheet where hyperlink was clicked Dim strWs As String Dim strTgt As String Dim strRng As String Dim strMsg As String Dim lCut As Long On Error GoTo errHandler strMsg = "Problem with follow hyperlink code" Select Case Sh.Name Case "Instructions", "MyLinks" GoTo exitHandler Case Else strWs = Target.Parent If ActiveSheet.Name <> strWs Then 'get the target cell/range strTgt = Target.SubAddress lCut = InStr(1, strTgt, "!") strRng = Right(strTgt, Len(strTgt) - lCut) With Sheets(strWs) strMsg = "Could not select the target" .Visible = True .Activate .Range(strRng).Activate End With End If strMsg = "Could not hide the sheet" Sh.Visible = False End Select exitHandler: Exit Sub errHandler: MsgBox strMsg Resume exitHandler End Sub |
Get the Excel Hyperlink Sample Files
|
More Tutorials |
Last updated: May 14, 2023 1:17 PM