Excel.Tips.Net ExcelTips (Menu Interface)

Extracting URLs from Hyperlinks

Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Extracting URLs from Hyperlinks.

Mezga has a series of cells that contain hyperlinks. These hyperlinks consist of words such as "click here" or "more information." In other words, each hyperlink contains display text that is different from the underlying URL that is activated when the link is clicked. Mezga would like to know if there is a way, without using a macro, to extract the underlying URL for each of these hyperlinks and place that URL into a different cell.

Without using macros, you can do this:

  1. Right-click a hyperlink. You'll see a Context menu appear.
  2. From the Context menu, choose Edit Hyperlink. Excel displays the Edit Hyperlink dialog box. (See Figure 1.)
  3. Figure 1. The Edit Hyperlink dialog box.

  4. Select and copy (Ctrl+C) the entire URL from the Address field of the dialog box.
  5. Press Esc to close the Edit Hyperlink dialog box.
  6. Paste the URL into any cell desired.

Note that this is for a single hyperlink. If you have a whole bunch of hyperlinks in a worksheet and you want to recover the URLs, you need to do this for each and every hyperlink. Obviously this can get tedious very quickly.

The cure for tedium—like them or not—is a macro. With a macro, getting at the underlying URL for a hyperlink is child's play. All the macro needs to do is pay attention to the Address property of the hyperlink. The following is an example of a macro that will find each hyperlink in a worksheet, extract each one's URL, and stick that URL in the cell directly to the right of the hyperlink.

Sub ExtractHL()
    Dim HL As Hyperlink
    For Each HL In ActiveSheet.Hyperlinks
        HL.Range.Offset(0, 1).Value = HL.Address
End Sub

Instead of a "brute force" macro, you could also create a user-defined function that would extract and return the URL for any hyperlink at which it was pointed:

Function GetURL(rng As Range) As String
    On Error Resume Next
    GetURL = rng.Hyperlinks(1).Address
End Function

In this case you can place it where you want. If you want, for example, the URL from a hyperlink in A1 to be listed in cell C25, then in cell C25 you would enter the following formula:


ExcelTips is your source for cost-effective Microsoft Excel training. This tip (3281) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Extracting URLs from Hyperlinks.

Related Tips:

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!


Leave your own comment:

  Notify me about new comments ONLY FOR THIS TIP
Notify me about new comments ANYWHERE ON THIS SITE
Hide my email address
*What is 5+3 (To prevent automated submissions and spam.)
           Commenting Terms

Comments for this tip:

Ying    19 Dec 2016, 22:01
Hi I would like to copy a URL website link from one cell to another. When this one cell that contains the website link is updated, I would like for all the other cells to have updated URL website links too. How can I do this?

LH    10 Oct 2016, 12:59
Thank you so much for this post. You have saved me a bunch of time. ExtractHL macro worked perfectly for me.
Kathleen    03 Oct 2016, 13:20
Many thanks! A colleague painstakingly put over 100 hyperlinks in cells with shorter captions, not realizing I would have to pull them all out again to copy them out to other documents. Ran Sub ExtractHL once. Boom! Great tip.
Thankful    05 Aug 2016, 00:19
Function GetURL(rng As Range) As String
    On Error Resume Next
    GetURL = rng.Hyperlinks(1).Address
End Function

This worked like MAGIC! thanks for being awesome!
Willy Vanhaelen    18 Jun 2016, 05:58
@Rob Cooper

HL.Address truncates everything after and incuding # (hash sign). I do not see a solution to this.
Rob Cooper    14 Jun 2016, 15:08
I tried the GetUrl function, but ran into the following difficulty.
The address of the hyperlink on which I applied GetUrl is:


i.e. it is a particular topic in an on-line book.

GetUrl only returned
the address only up to the first 'htm'.

Any ideas for how to return the whole address?

Rob    27 May 2016, 13:42
Thanks, you rock!
Leonardo    02 May 2016, 13:51
Nice tip, simple and very effective.

Willy Vanhaelen    13 Mar 2016, 06:54
FORMULATEXT is introduced in Excel 2013.
These tips apply to Excel 97 ... 2003.
Spriteup    12 Mar 2016, 10:32
Or without Macro fuction just:

where B1 is HYPERLINK.

Our Company

Sharon Parq Associates, Inc.

About Tips.Net

Contact Us


Advertise with Us

Our Privacy Policy

Our Sites


Beauty and Style




DriveTips (Google Drive)

ExcelTips (Excel 97–2003)

ExcelTips (Excel 2007–2016)



Home Improvement

Money and Finances


Pests and Bugs

Pets and Animals

WindowsTips (Microsoft Windows)

WordTips (Word 97–2003)

WordTips (Word 2007–2016)

Our Products

Helpful E-books

Newsletter Archives


Excel Products

Word Products

Our Authors

Author Index

Write for Tips.Net

Copyright © 2017 Sharon Parq Associates, Inc.