Creating a Dynamic Hyperlink

by Allen Wyatt
(last updated March 22, 2014)

16

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 paramaeter (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. Yu 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 user 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),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, and 2013.

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

Modifying the Backup Copy File Name

Backup files, created automatically by Word, have the filename extension WBK and start with the words "Backup of." If you ...

Discover More

Creating Hyperlinks from E-mail Addresses

Got a document that has a whole raft of e-mail address in it? You can easily convert all of them to clickable hyperlinks by ...

Discover More

Determining a Worksheet's Number

When you add a new worksheet to a workbook, it receives a meaningful name such as "Sheet4" or "Sheet17." If you want to ...

Discover More

Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!

More ExcelTips (ribbon)

Using Drag-and-Drop to Create a Hyperlink

If you open workbooks in two instances of Excel, you can use drag-and-drop techniques to create hyperlinks from one workbook ...

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

Links to Hyperlinks

Hyperlinks in a worksheet can be helpful or essential, depending on the nature of your data. If you create a link to a ...

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

2016-10-07 04:27:21

Vitali

Great, thank you, Allen!


2016-07-17 05:23:35

SAMUEL PALANDE

How do we create a dynamic hyperlink to a cell value so that on click of that value focus should jump to this value in single worksheet where its details are present


2016-01-25 22:55:50

Sourin Sett

i was wondering how to create dynamic hyperlink to a particular cell of another xlsx file in the same folder?


2016-01-25 17:24:39

Dave

Hello,
I was wondering if you knew a way to incorporate this into a hyperlink to open another seperate workbook/spreadsheet to a named range.

~ Thx.


2016-01-20 06:32:52

xlnc

"This tip (13034) applies to Microsoft Excel 2007, 2010, and 2013."

FORMULATEXT is worksheet function in Excel 2013+


2016-01-19 05:36:56

Sukhpal Singh

Hi Allen,

I am having trouble figuring out why after putting multiple hyperlinks in a worksheet, it continues to re-direct me to the latest hyperlink i have created- the same link for each different link.

I would grateful if you can advise me.

Thank you.


2015-09-21 14:12:40

Gorpo

how can i create a hyperlink to sheet by referencing a cell value? my main sheet column A has index numbers 1, 2, 3 etc. My sheets are named 1, 2, 3 etc.


2015-09-10 02:59:10

Jeff Brown

Hello,

Is there a hyperlink formula i can use that will open either a JPG or PNG file.

my current formula is;
=HYPERLINK(CONCATENATE("T:MarketingCosting TemplateImages",F5,"",D5,".jpg"),"View")

obviously this will only open the .jpg file. how do i adjust this so it can open the file regardless of whether it is saved in JPG or PNG format?

Thanks.


2015-07-13 01:16:14

kawal

I want to do a statement in excel and want to put a specific cell reference in between the statement, is it possible if yes how


2015-04-02 20:29:04

John

Hi
I have solved the problem i posed a couple of days ago. I am embarrassed as to how simple it was.
If anyone is interested...

=Hyperlink(index(Array,Row,Column)) and manipulating the second and third arguments by calculation. I.e the row or column can become a constant depending what you wish to achieve.


2015-04-01 22:21:16

John

Hi
I have been using the following hyperlink for a long time now without any problems. However, I now wish to reference a row; rather than a column and then calculate the column number instead of the row number.
Present dynamic hyperlink:
=HYPERLINK("#Main!C"&Z9,"Friendly")
Destination: is column C at row number specified in cell Z9.

Can you help?


2014-10-02 00:48:35

Curious

I want to make a formula where I provide a web site and it's dynamic variable like this:
Sample cell A1. Value 12345

http://www.mywebsite.com/pages/product.aspx?sku=[A1]

the result must be an internet clickable hyperlink on the spreadsheet like this:

http://www.mywebsite.com/pages/product.aspx?sku=12345

Help?


2014-03-28 07:02:13

Bryan

Don: I agree that deletions shouldn't be an issue for the developer -- they should cause just as much trouble with any of these formulas than they would with anything else.

And ooops! Thanks for catching the typo. You managed to expose a secret about how I develop formulas: I break them into multiple cells, then combine them at the end.


2014-03-27 15:23:18

Don

Let me start by saying I learned a load from this tip, both the original from Allen and feedback from Bryan. When I saw the request from Mark I got stuck at the problems in using the Insert Hyperlink function in the UI, and reverted to thinking about VBA and workbook/worksheet events.

In my mind this is the kind of feature that would be built near the end of the development cycle, after formulas and headers and the input cells are all defined it seems like the likelihood of the deletion of target ranges would be slight, i.e. the developer would know what ranges would be in danger of deletion and protect the target ranges before release to the users.

There is one typo in Bryan's formula: an extra equal sign in the middle. Otherwise, it worked beautifully with just a copy/paste and editing for the name of the worksheet.


2014-03-24 09:27:14

Bryan

1) You've got a typo in the 5th paragraph ("Yu instead of "You").

2) Helper cells don't get around "all of these problems" -- there's no solution to the "linking to a deleted cell" problem. The only way to get around this problem would be to have your cell reference as A1:XFD1048576... which still will throw an error if you delete all the cells in the sheet.

3) If you use the CELL function, you don't need to use the multi-helper-cell solution: =HYPERLINK(CELL("address",MySheet!A1), "Jump There")

4) The problem statement sounds like Mark wants the friendly name to be the target worksheet name, so the entire formula would be: =HYPERLINK(CELL("address",MySheet!A1), =LEFT(MID(CELL("address",MySheet!A1),FIND("]",CELL("address",MySheet!A1))+1,9^9),FIND("!",CELL("address",MySheet!A1))-FIND("]",CELL("address",MySheet!A1))-1))

4a) My formula in step 4 is a good candidate for helper cells/named ranges, since the same calculation is done repeatedly. Using named ranges, the formula would be: =HYPERLINK(wkst_address,wkst_name)

Where:

wkst_address = CELL("address",MySheet!A1)

wkst_name = MID(wkst_address,l_pos,r_pos-l_pos)

l_pos = FIND("]",wkst_address)+1

r_pos = FIND("!",wkst_address)


2014-03-24 09:10:59

Mark

Awesome! THANKS Allen!


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.