How to use the HYPERLINK function
What is the HYPERLINK function?
The HYPERLINK function allows you to build a link in a cell pointing to something else like a file, workbook, cell, cell range, or webpage.
You can then press with left mouse button on that link to open a file or quickly navigate to a location in a workbook.
Table of Contents
- Excel function syntax
- Function arguments
- How to select a cell containing a hyperlink?
- HYPERLINK function not working
- How to create a link to a cell
- How to create a link to a cell range
- How to create a link to another worksheet
- How to create a link to a workbook
- How to create a link to a named range
- How to create a link to an Excel Table
- How to create a link to a file
- How to create a link to a webpage
- How to create a link based on cell value
- Get Excel file
- Locate lookup values in an Excel table
1. HYPERLINK Function syntax
HYPERLINK(link_location, [friendly_name])
2. HYPERLINK Function Arguments
Link_location | Required. Depending on what you want to create a link to you have these options:
|
friendly_name | Optional. A value or a cell reference used by the HYPERLINK function to show link text, in the cell. This argument is optional, the HYPERLINK function displays the link location if the argument is missing. |
3. How to select a cell containing a hyperlink?
To select a cell without performing the hyperlink action press and hold on the cell until a cross appears, see the animated image above.
4. HYPERLINK function not working
The HYPERLINK functions first argument is not easy to type, there are a few things to remember:
- full path if the workbook or file is not in the same directory as the active workbook
- workbook name with leading and trailing bracket
- worksheet name with leading and trailing single quote if the name contains a space character
- exclamation mark between worksheet name and cell address
Below are common errors described.
4.1 Reference isn't valid error
The image above shows an error that Excel returns if the worksheet name is missing or the worksheet name contains space characters.
HYPERLINK(link_location, [friendly_name])
The link_location argument must contain a reference to the workbook name, worksheet name, exclamation mark between worksheet name and cell address, and a cell address if you want to link to an item in a workbook.
Formula in cell B3 that returns an error:
Worksheet reference "Link to a cell" above contains space characters, use a leading and trailing single quote or apostrophe to avoid the "Reference isn't valid" error.
Formula in cell B3 that works:
4.2 Cannot open the specified file error
The image above demonstrates an error that is returned if the workbook name is missing in the link_location argument.
HYPERLINK(link_location, [friendly_name])
Formula in cell B3 that returns an error:
The link_location argument above doesn't contain a reference to the workbook name, use leading and trailing brackets to avoid "Cannot open the specified file" error.
Formula in cell B3 that works:
4.3 Excel found a problem with one or more formula references in this worksheet
The image above shows an Excel error if the first argument in the HYPERLINK function is not correct.
The dialog box shows "Excel found a problem with one or more formula references in this worksheet. Check that the cell references, range names, defined names, and links to other workbooks in your formulas are all correct.
Formula in cell B3 that returns an error:
The link_location argument above doesn't contain a reference to a cell.
Formula in cell B3 that works:
5. How to create a link to a cell
The image above demonstrates how to link to a specific cell using the HYPERLINK function.
Formula in cell B3:
HYPERLINK(link_location, [friendly_name])
The link_location argument must contain a reference to the workbook, worksheet, and cell address. [friendly_name] argument lets you specify the hyperlink text to show in the cell.
Note the exclamation mark between the worksheet and cell address.
6. How to create a link to a cell range
The image above demonstrates how to link to a specific cell range using the HYPERLINK function. The cell range is selected if you press with left mouse button on the hyperlink.
Formula in cell B3:
HYPERLINK(link_location, [friendly_name])
The link_location argument must contain a reference to the workbook, worksheet, and a reference to a cell range. [friendly_name] argument lets you specify the hyperlink text to show in the cell.
Note the exclamation mark between the worksheet and cell address.
7. How to create a link to another worksheet
The image above demonstrates how to link to a specific worksheet using the HYPERLINK function.
Formula in cell B3:
HYPERLINK(link_location, [friendly_name])
8. How to create a link to a workbook
The image above demonstrates how to link to a specific workbook using the HYPERLINK function.
Formula in cell B3:
HYPERLINK(link_location, [friendly_name])
Note that a reference to the workbook name only is valid. Remember to reference the full path if the workbook is not in the same directory.
=HYPERLINK("[TEXT function.xlsx]","Link to Text function.xlsx")
9. How to create a link to a named range
The image above demonstrates how to link to a specific named range using the HYPERLINK function.
Formula in cell B3:
HYPERLINK(link_location, [friendly_name])
You need to specify the path, workbook name, and the name of the named range, the example above has no path specified. The workbook is in the same folder as the active workbook.
Read more about named ranges: Define and use names in formulas
10. How to create a link to an Excel Table
The image above demonstrates how to link to a specific named range using the HYPERLINK function.
Formula in cell B3:
HYPERLINK(link_location, [friendly_name])
You need to specify the path, workbook name, and the name of the Excel Table. The example above has no path specified, the workbook is in the same folder as the active workbook.
Read more about Excel Tables
11. How to create a link to a file
The image above shows how to link to a specific file using the HYPERLINK function.
Formula in cell B3:
HYPERLINK(link_location, [friendly_name])
You need to specify the path, file name, and file extension. The example above links to a pdf file named temp.pdf in a temp folder on harddrive c:\.
12. How to create a link to a webpage
The image above shows how to link to a specific website using the HYPERLINK function.
Formula in cell B3:
HYPERLINK(link_location, [friendly_name])
You need to specify the url to the website you want to link. The example above links to Google.
13. How to create a link based on cell value
If you use a cell reference as an argument you can make the function dynamic. This allows the HYPERLINK function to change depending on the value in the cell that the cell reference points to.
Formula in cell D3:
You can create formulas that lookup a value and return a link to that value using this technique.
Here are some articles:
Locate lookup values in an Excel table [HYPERLINK]
Navigate to first empty cell using a hyperlink formula
Create a hyperlink linked to the result of a two-dimensional lookup
How to quickly find the maximum or minimum value [Formula]
Useful resources
HYPERLINK function - Microsoft support
15. Locate lookup values in an Excel Table
This section demonstrates a formula that returns a hyperlink pointing to a location based on a lookup value. When you press with left mouse button on the cell that contains the hyperlink text, Excel takes in an instant to that location in the table.
The formula is dynamic meaning if you change the search value the formula changes the location and the hyperlink text instantly.
Formula in cell C3:
This formula finds only the first instance of the search value, se further down the article for a formula that returns multiple results.
The Excel defined Table is located on worksheet "Table", the image above shows some records of that Excel defined Table.
Explaining formula in cell C3
I recommend you use the "Evaluate Formula" feature in Excel to examine calculations step by step.
Select cell C3, go to tab "Formulas" on the ribbon and press with left mouse button on the "Evaluate Formula" button.
(The formula shown in the above image is not the formula used in this article.)
Press with left mouse button on "Evaluate" button to see the next step in the formula calculations.
Step 1 - Return the relative position of an item in an array that matches a specified value
The MATCH function returns the relative position of a value in a column.
MATCH(A2, Table1[Number], 0)
becomes
MATCH(0.260463529541505, {0.129000449044708;0.440537695535749;0.532039509437168; ...}, 0)
(Array shortened)
and returns 39.
Step 2 - Create a cell reference as text
The ADDRESS function returns a cell reference based on a row and column number. ADDRESS(row_num, column_num, [abs_num], [a1], [sheet_text])
ADDRESS(MATCH(A2, Table1[Number], 0)+MIN(ROW(Table1[Number]))-1, 5)
becomes
ADDRESS(39+MIN(ROW(Table1[Number]))-1, 5)
The MATCH function returns a relative position, it does not take into account cells above the Excel Table. We need to determine how many cells are above the Excel Table.
ADDRESS(39+MIN(ROW(Table1[Number]))-1, 5)
becomes
ADDRESS(39+MIN(3)-1, 5)
becomes
ADDRESS(41, 5)
The second argument is the column number and is hardcoded into the formula, you must change this to the column number to a number representing the column you search.
ADDRESS(41, 5)
and returns $E$41
Step 3 - Create a shortcut to a cell in sheet Table
The HYPERLINK function lets you build a hyperlink in a cell. It has the following arguments: HYPERLINK(link_location, [friendly_name])
HYPERLINK("[Find values quickly.xlsx]Table!"&ADDRESS(MATCH(A2, Table1[Number], 0)+MIN(ROW(Table1[Number]))-1, 5), "Go to "&ADDRESS(MATCH(A2, Table1[Number], 0)+MIN(ROW(Table1[Number]))-1, 5))
becomes
=HYPERLINK("[Find values quickly.xlsx]Table!$D$41, "Go to $D$41")
The animated image above shows what happens when you press with left mouse button on a hyperlink, note that the lookup value match the number.
What if there are multiple values matching your lookup value?
Array formula in cell C3:
How to create an array formula
- Copy above array formula
- Select cell B2
- Press with left mouse button on in formula bar
- Paste array formula
- Press and hold Ctrl + Shift
- Press Enter
How to copy array formula
- Select cell B2
- Copy cell (Ctrl + c)
- Select cell range C2:E2
- Paste (Ctrl + v)
- Select cell range B2:E2
- Copy (Ctrl + c)
- Select cell range B3:E7
- Paste (Ctrl + v)
Explaining formula in cell B2
Step 1 - Check if a condition is met and return corresponding row value if TRUE
IF($A2=Table1[Number], ROW(Table1[Number]), "")
becomes
IF(0.260463529541505={0.129000449044708;0.440537695535749;0.532039509437168; ...}, {3, 4, 5, ...}, "")
and returns
{""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; 41; ... ; ""} (Array shortened)
Step 2 - Return the k-th smallest value
SMALL(array, k)
SMALL(IF($A2=Table1[Number], ROW(Table1[Number]), ""), COLUMNS($A$1:A1))
becomes
SMALL({""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; 41; ... ""}, 1)
and returns 41.
Step 3 - Create a shortcut to a cell in sheet Table
HYPERLINK("[Find values quickly.xlsx]Table!"&ADDRESS(SMALL(IF($A2=Table1[Number], ROW(Table1[Number]), ""), COLUMNS($A$1:A1)), 4), "Go to "&ADDRESS(SMALL(IF($A2=Table1[Number], ROW(Table1[Number]), ""), COLUMNS($A$1:A1)), 4))
returns
HYPERLINK("[Find values quickly.xlsx]Table!$D$41, "Go to $D$41)
'HYPERLINK' function examples
The image above shows a formula in cell C2 that searches for a value based on two conditions specified in […]
The image above shows two hyperlinks, the first hyperlink lets you select a data set automatically based on a dynamic […]
This article demonstrates formulas that return the last value in a given cell range or column. The image above shows […]
Functions in 'Lookup and reference' category
The HYPERLINK function function is one of 25 functions in the 'Lookup and reference' category.
Excel function categories
Excel categories
17 Responses to “How to use the HYPERLINK function”
Leave a Reply
How to comment
How to add a formula to your comment
<code>Insert your formula here.</code>
Convert less than and larger than signs
Use html character entities instead of less than and larger than signs.
< becomes < and > becomes >
How to add VBA code to your comment
[vb 1="vbnet" language=","]
Put your VBA code here.
[/vb]
How to add a picture to your comment:
Upload picture to postimage.org or imgur
Paste image link to your comment.
Contact Oscar
You can contact me through this contact form
Ah there we go, I had some issues commenting on this before.
Firstly, thank you for these excellent examples, very helpful and instructive.
I'm an accountant and the second part of this article (hyperlinking to multiple matches) would be fantastically useful to me but unfortunately I usually work in a column format, not horizontally as the example shows.
Would you mind showing me how I would need to change the formula to reflect multiple matches in a single column. So that if columns C,D,E were cleared and A2 was repeated in say A4 and A5 then A4 would be the next match and say "Go to D260" (currently C2 as it is showing the matches horizontally). As there would be no further matches then A5 would be blank and then the matches for A6 would then continue vertically.
Thank you very much for your time and I hope you don't mind showing me how to achieve this result.
Kind regards,
Oliver
Oliver,
I am happy you like it!
Array formula in cell B2:
Get the Excel *.xlsx file
Find-values-quicklyv2.xlsx
Hi Oscar,
Thanks so very much for the reply. I had tried using countif but clearly I wasn't putting it in the right spot!
Above you've explained very clearly what is happening with the rows etc and so I'm quite happy with this, unfortunately I am having trouble tailoring this for my own purpose which is to not reference a table(Table1[Number]) but rather a sheet (Sheet5!D:D). Somehow when I change the references, something unexpected happens and the formula no longer functions quite the same. Would you be so kind as to show me the correct usage for this method?
So for instance if I had the same sort of numbers but in column D in say, Sheet5, not a table.
My other question is whether there is a method for achieving the same result in VBA. While I have seen many attempts at creating separate lists showing differences or matches, this is quite unique in that it allows for navigation of a table (which is more reflective of what a manual process would be if I had to tick through each match).
Thank you very much for your help,
Oliver
Oliver,
Change the table references to absolute cell references.
Example:
to
Note! COUNTIF($A$2:A2, A2) uses both relative and absolute cell references.
Hi Oscar,
Thanks so very much for the reply. I had tried using countif but clearly I wasn't putting it in the right spot!
Above you've explained very clearly what is happening with the rows etc and so I'm quite happy with this, unfortunately I am having trouble tailoring this for my own purpose which is to not reference a table(Table1[Number]) but rather a sheet (Sheet5!D:D). Somehow when I change the references, something unexpected happens and the formula no longer functions quite the same. Would you be so kind as to show me the correct usage for this method?
So for instance if I had the same sort of numbers but in column D in say, Sheet5, not a table.
My other question is whether there is a method for achieving the same result in VBA. While I have seen many attempts at creating separate lists showing differences or matches, this is quite unique in that it allows for navigation of a table (which is more reflective of what a manual process would be if I had to tick through each match).
Thank you very much for your help,
Oliver
hai oscar,
I have a table with customers as column & products as rows. Price may different to each customer and product. i am using the following formula to find out the rate of an item for a particular customer;
"=IF(INDEX(TABLE3,MATCH(REF_ID,INDEX(TABLE3,,1),0),MATCH(REF_prod,INDEX(TABLE3,1,),0))<=0,"PLEASE INSERT A RATE",(INDEX(TABLE3,MATCH(REF_ID,INDEX(TABLE3,,1),0),MATCH(REF_prod,INDEX(TABLE3,1,),0)))).
now i want to locate/hyperlink the particular cell intersecting the customer reference and product reference. can u pls help me
RAJ.A.D,
read this post: Locate a particular cell in a table
[…] out Oscar Cronquist’s post about dynamic […]
Hello oscar
I wanted to use your formula and play a bit with it but the file doesn't seem to work when I got (error cant open the specific file when I press a hyperlink) now I wanted to know if it is possible to extend that the lookup value is now compared with the row number can be searched in 3 different rows? And also is it possible to do it over several sheets?
Hello,
How about if I am using open office?
Faith
Sorry, I don't know.
I have 18 columns and more than 40 rows data, and I want peak the largest value among and lookup the corespondent value (heading and field name) with the data,
I tray =index(array,match(lookup value, array, 0)) returns #N/A,
array assume from $C$4:$T$391
lookup value AH4,
esse
Can you post your formula, there seems to be nothing wrong with the one you provided.
You get a #N/A error if the lookup value is not found.
Awesome!, Thanks, you made my day, really relieved.
Oscar,
What is the best way to get around the characters limit when using HYPERLINK? Thanks
I get the message " Cannot open the specified file"
Mark,
You need to enter the name of your workbook file in the formula:
[Find values quickly.xlsx]Table!
Find values quickly.xlsx is my file name.