Creating a Dynamic Hyperlink

Written by Allen Wyatt (last updated December 26, 2020)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365


3

Mark wonders how to create a hyperlink to a worksheet in the same workbook. The name of the worksheet will change, so he thinks the link will have to be "dynamic." He would also like the "friendly name" for the hyperlink to change with the worksheet name.

There are a few ways that this can be approached. The first is to create a simple hyperlink to the destination using the HYPERLINK function. The syntax for the function is as follows:

=HYPERLINK(link_location, [friendly_name])

Note that the second parameter (the friendly name) is optional but should be used in Mark's scenario. If you want to link to another worksheet, then all you need to do is provide the address of a cell on that worksheet, in this manner:

=HYPERLINK("[myWorkBook.xlsx]MySheet!A1", "Jump There")

This provides a hyperlink to cell A1 on the worksheet named "MySheet." This works great, provided that there is no name change to "MySheet." If the name is changed or if the referenced cell is deleted, then the hyperlink no longer works.

There is an easy way to get around this potential problem, but it introduces a new potential problem. You can create a named range on the destination worksheet, and then use the named range in the HYPERLINK function, in this manner:

=HYPERLINK("#MyRange","Jump There")

Note that the range name must be preceded by a # sign and enclosed in quotes. Clicking the link displays whatever worksheet contains the named range and selects that range. It is more versatile than the earlier approach because it doesn't matter if you rename the worksheet containing the named range. It does matter, however, if the named range is deleted. (If only a part of the named range is deleted, Excel adjusts fine. It only balks if the entire named range is deleted.)

To get around all of these problems requires the use of helper cells. (You could also use a simple macro or two, but that may be overkill for Mark's needs.) As an example, put the following into cell A24:

=MySheet!A1

The cell will show whatever is in cell A1 on MySheet. If you later change the name of MySheet (the actual sheet name), then the formula automatically changes. If you insert or delete rows or columns in MySheet, the reference to cell A1 in the formula won't change. This allows you to always have a valid worksheet and cell reference. In order to get that reference into a form that you can use in the HYPERLINK function, place the following formula in cell B24:

=MID(FORMULATEXT(A24),2,99)

The FORMULATEXT function converts the formula in cell A24 into a text string and the addition of the MID function pulls off the equal sign from the front of the formula. The formula, as shown, allows for very long worksheet names, up to 96 characters (the other three characters are "!A1"). You can then use the following formula to create the actual hyperlink:

=HYPERLINK("[myWorkBook.xlsx]" & B24, "Jump There")

The hyperlink target is always dynamic and stable, which is exactly what is needed. It should be noted, though, that the FORMULATEXT function was introduced in Excel 2013; it won't work in earlier versions of the program.

I haven't spent much time talking about the friendly name portion of the HYPERLINK function. That's because you could easily change it to reference just about anything you want. You could, for instance, have it reference a different cell which, in turn, displays a value based on whatever formula you desire:

=HYPERLINK("#MyRange",A7)

This example grabs the friendly name from whatever is in cell A7. Change what is in cell A7, and the friendly name updates at the same time.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (13034) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Elapsed Days as Years, Months and Days

Need to know how many days there are between two dates? It's easy to figure out—unless you need the figure in ...

Discover More

Plotting Times of Day

Got a chart created from your worksheet? You can plot times of day in the chart if you apply the simple techniques in ...

Discover More

Indirect References to a DSUM Parameter

Indirect references can be very helpful in formulas, but getting your head around how they work can sometimes be ...

Discover More

Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!

More ExcelTips (ribbon)

Automatic Text in an E-mail

When creating an e-mail address hyperlink using the Insert Hyperlink dialog box, Excel allows you to enter a subject for ...

Discover More

Sending an E-mail when a Due Date is Reached

Wouldn't it be great if Excel could automatically e-mail you when a due date is reached? It can, if you are using Outlook ...

Discover More

Getting Rid of All Hyperlinks

Need to get rid of all the hyperlinks in a worksheet? It's easy when you use this single-line macro.

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 5 - 5?

2021-07-06 05:05:02

Sylvia

This worked perfectly - until I used it on an Excel Online file, and then... it didn't.

I tried using Tom's suggestion of referring to the sheet instead of the file, but that took me to the helper cell, not the original data.

Eventually I found another site that offered this: =HYPERLINK("#"&"Data!B"&(MATCH(B3,Data!$B$3:$B$26,0)+2),"Click Here to See Data")

See https://trumpexcel.com/create-dynamic-hyperlinks-in-excel/ for details

I apologise for sending people elsewhere, because I really do love Allen's work and often end up here when I'm looking for Excel answers!


2020-12-26 14:18:12

Tom Kadlec

Allen,

If the sheet you want to link to is in the same workbook, you can use this format:

=HYPERLINK("#'MySheet'!A1","Jump There")

The # sign used in this way indicates that the link is to a sheet in the current workbook.


2020-12-26 10:48: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. You can read about more issues re. the HYPERLINK function in this PDF: https://drive.google.com/file/d/1vAXFMwX43N7b-6fEhdY5E0PZRmIQ9zlA/view
which is part of My Excel Toolbox. See https://sites.google.com/view/MyExcelToolbox/


This Site

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.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.