=HYPERLINK(link_location, [friendly_name])
- link_location - The path to the file or page to be opened.
- friendly_name - [optional] The link text to display in a cell.
Using the HYPERLINK function
The HYPERLINK function creates a hyperlink to a given destination with a "friendly name", which is simply the anchor text. You can use HYPERLINK to construct a clickable hyperlink with a formula. The HYPERLINK function can build links to other cells in a workbook, other sheets, named ranges, other workbooks, pages on the internet, or files on network servers. You can also use HYPERLINK to create email links.
The HYPERLINK function takes two arguments: link_location and friendly_name. Link_location is the destination or path the link should follow, entered as text. Friendly_name is the text that will be displayed with the link.
When a user clicks a cell that contains the HYPERLINK function, Excel will open the file or page specified by link_location. Link_location can be a cell reference or named range, a path to a file stored on a local drive, a path a file on a server using Universal Naming Convention (UNC), or an internet path in Uniform Resource Locator (URL) format.
Example #1 - link to cell
To link to another cell in the same worksheet, prefix the cell with "#":
=HYPERLINK("#Z100","link to Z100") // cell in same sheet
Example #2 - link to sheet
To link to another sheet in the same workbook, use "#" with the Sheet name like this
=HYPERLINK("#Sheet2!A1","Sheet2") // sheet2 in same workbook
If the sheet name contains a space, you'll get an invalid reference error with the formula above. In that case, you'll need to enclose the sheet name in single quotes (') like this:
=HYPERLINK("#'Sheet 2'!A1","Sheet 2") // sheet name with space
Example #3 - external link
To link to https://exceljet.net/ with the text "exceljet":
=HYPERLINK("https://exceljet.net/","exceljet")
Example #4 - email link
To link to a valid email address in A1, you can concatenate "mailto:" like this:
=HYPERLINK("mailto:"&A1,"email") // link to email address in A1
With two email addresses in A1 and A2, you can create a link like this:
=HYPERLINK("mailto:"&A1&","&B1,"email") // two emails
This formula example explains how to construct a more complete mailto email link with cc, subject, body, etc.
Character limit
The link_location argument is limited to 255 characters. If the link is longer than 255 characters, HYPERLINK returns a #VALUE! error:
=HYPERLINK(A1,"link") // #VALUE! if URL in A1 > 255 characters
Unfortunately, there is no way to work around this limit with a formula. The limit applies to the final value of link_location, so assembling a long URL with concatenation, or storing the URL in a cell or named range, will still result in a #VALUE! error. However, there are several practical ways to deal with a long URL:
- Trim the URL. Many long URLs contain optional query parameters (the text that follows "?"), often added for tracking purposes. You can frequently remove these parameters and get under the limit. Test the trimmed URL in a browser first to make sure it still works.
- Use a URL shortening service. Services like TinyURL and Bitly will convert a long URL into a short redirect link that works fine with HYPERLINK. The trade-off is that the link now depends on a third-party service.
- Skip the formula. Excel's Insert Link command (Control + K) creates hyperlinks directly in a cell without the HYPERLINK function, and supports much longer URLs. You lose the ability to build the link dynamically, but the 255-character limit no longer applies.
Notes
- Link_location should be supplied as a text string in quotation marks or a cell reference that contains the link path as text.
- Link_location is limited to 255 characters; longer links cause a #VALUE! error. See Character limit above.
- If friendly_name is not supplied, the HYPERLINK will display link_location as the friendly_name.
- To select a cell that contains HYPERLINK without following the link, use arrow keys or right-click the cell.