Creating a Dynamic Hyperlink

by Allen Wyatt
(last updated December 26, 2020)

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 Office 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

Creating a New Document in VBA

When working with documents in a macro, it makes sense that you may need to create a document from time to time. Here's ...

Discover More

Opening a Workbook but Disabling Macros

Macros that run automatically when you open or close a workbook are quite helpful. You may not want them to run, however, ...

Discover More

Mirroring Documents

Have you ever wanted to have a Word document be accessible through two different folders? Here are several ways you can ...

Discover More

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 2013 For Dummies today!

More ExcelTips (ribbon)

Can't Use Hyperlinks

Before some features in Excel can function properly, you must have the correct permissions set for the user of the ...

Discover More

Special Characters In Hyperlinks

Do you use special characters (such as the pound sign) in your worksheet names? If so, you could run into problems ...

Discover More

Hyperlinks No Longer Work in a Workbook

Hyperlinks can be a great timesaver and very convenient. Unless, of course, if they don't work as you expect. This tip ...

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}] 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 9 + 8?

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.