Creating a Dynamic Hyperlink

by Allen Wyatt
(last updated December 26, 2020)

2

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

Moving Through a Table in a Macro

Do you need to step through a table, cell by cell, in a macro? It's easy to do using the Move method, as described in ...

Discover More

Prohibiting Single-Digit Entries in a Cell

The Data Validation capabilities of Excel can be very helpful when you are trying to control what people can enter into a ...

Discover More

Vertical Lines in Word

Lines can help to organize the data on a page or make certain points clearer. Word provides several different ways you ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More ExcelTips (ribbon)

Drop-Down List of Hyperlinks

Creating a drop-down list with Excel's data validation feature can be a nice touch for a worksheet. What if you want the ...

Discover More

Pasting a Hyperlink

Need a quick link within a document to some external data? You can paste information so that Excel treats it just like a ...

Discover More

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
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 6 - 6?

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.