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.

Extracting URLs from Hyperlinks

Written by Allen Wyatt (last updated September 25, 2020)
This tip applies to Excel 97, 2000, 2002, and 2003


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:



If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

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.

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


Getting Rid of All Hyperlinks

Need to get rid of all the hyperlinks in a worksheet? It's easy when you use this single-line macro.

Discover More

Editing a Hyperlink

Excel will cheerfully keep track of all sorts of hyperlinks for you. If you want to change the hyperlink in some way, ...

Discover More

Making Columns the Same Length

Balancing the length of each column in a multi-column page layout can be a challenge. Here's a quick way to get Word to ...

Discover More

Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!

More ExcelTips (menu)

Setting Web Fonts

Is your worksheet information destined for a Web page? Here's how you can specify the fonts that should be used when ...

Discover More

Specifying Your Target Monitor

When you create a worksheet that is destined for viewing on the Web, you will want to specify the monitor resolution you ...

Discover More

Linking to a Specific Page in a PDF File

The HYPERLINK function is great for linking to Web pages and some other resources, but it won't allow you to access a ...

Discover More

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.


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}] (all 7 characters, in the sequence shown) 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 8 - 7?

2022-05-24 19:00:51


Doesn't work. I get #NAME error
Function GetURL(rng As Range) As String
On Error Resume Next
GetURL = rng.Hyperlinks(1).Address
End Function


2021-11-30 10:56:38


thanks for the code. You saved me a lot of time.

I used the GetURL to extract URL from cells in Excel for Mac (v16) and works like charm.

2021-11-07 06:34:21


It is not working

2021-04-09 21:31:52

John Norris

User defined function Get URL does not work with O-365 Excel.

2020-10-16 05:58:56

Lorenz Michels

Thanks for the function GetURL! When using it, I discovered that it wouldn't return the complete URL if you had a query in it like:

This would only return:

Therefore I mimicked your function to be able to get the query as well:
Function GetSubURL(rng As Range) As String
On Error Resume Next
GetSubURL = rng.Hyperlinks(1).SubAddress
End Function

2020-07-08 09:54:39


Thanks Peter, that works for the server! Still truncated for local hard drive links.

2020-07-07 21:51:41


Retrieve the subaddress of the hyperlink to build the full address when the URL includes a #

With rng.Hyperlinks(1)
GetURL = .Address
if .SubAddress >"" then GetURL=GetURL & "#" & .SubAddress
End With

2020-07-06 11:31:23


Unfortunately this results in a truncated address, "..\..\don.MAIN\Documents\Other Folder(s)\MyFile.xlsx" instead of c:\users\don.main\etc. The same problem occurs with files on our server, which recently changed names (as did my don.main), although I was able to use VBA to find and replace the still visible \don.main\, I wasn't able to do so with the server links, whose name was truncated. I cannot use the "..\..\"part to search and replace because then I would destroy the links to files/folders on my computer. How do I get the FULL address?
Windows 10 Professional, Excel 2013.

2020-03-03 16:39:43

Patrick L. Gillen

Craig from 2019-11-06: excellent tip. I spent too long going nowhere with the VBA sub method. Thanks a lot!!!

2019-11-06 12:06:19


I found an easy way to convert hyperlinked text into simple URLS:

1) select and copy cells with hyperlinked text
2) open Outlook and paste text into draft email
3) change formatting from "HTML" to plain text
4) see text links convert to full URLs
5) copy these back into Excel

2019-07-18 23:19:59


Thanks! Very helpful and much used. Wondered why Microsoft does not include this as a standard function just like =Len(A1)

2019-03-09 10:06:53

Willy Vanhaelen

@Ricardo Ruiz
HL.Address truncates everything after and incuding # (hash sign). You can try to first replace # by %23. This might work.

2019-03-08 19:37:54

Ricardo Ruiz

This is a great Trick!! However, I am having an issue pulling the full hyperlink. Does the Marco not recognize the pound sign? I have over 1500 links I am trying to pull the full hyperlink and this would make my life a lot easier.

The Full hyperlink is =
The link the Marco Provides =

2019-01-22 18:46:36


Worked perfectly in Excel 2016/O365. Thanks!

2018-07-24 10:21:56

Gigi B

The information above is not helping me for some reason. I am attempting to pull hyperlinks from a main list, pull it into a sheet that is indexing certain information to another sheet that is listing information to cleaning index only those items that need to be viewed. I am having difficulty pulling the associated hyperlinks to the indexed information.

2018-04-13 08:55:58

Mike Mitchell

Thank you VERY MUCH. You saved me hours of work today. The simple custom function did a perfect job ef extracting more than 100 URLs from a spreadsheet, and I was then able to organize everything very quickly and get on with my day.

2017-11-16 00:49:43


Thank you!

2017-10-14 03:24:25

Greg Nottage

Hey. I'm normally pretty lazy commenting on stuff. But this tip has just saved me loads of time. Thanks!!

2017-08-09 20:34:06


your macro for extracting mjltiple url's from a list saved me a TON of work. THANK YOU VERY MUCH!! help very many more people than you know!!

2017-02-04 15:01:48

Mostafa Ibrahim

Thanks a lot for this tip, helped me so much, and saved a lot of time.

2016-12-19 22:01:33


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?


2016-10-10 12:59:40


Thank you so much for this post. You have saved me a bunch of time. ExtractHL macro worked perfectly for me.

2016-10-03 13:20:11


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.

2016-08-05 00:19:25


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!

2016-06-18 05:58:07

Willy Vanhaelen

@Rob Cooper

HL.Address truncates everything after and incuding # (hash sign). I do not see a solution to this.

2016-06-14 15:08:46

Rob Cooper

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?


2016-05-27 13:42:09


Thanks, you rock!

2016-05-02 13:51:45


Nice tip, simple and very effective.


2016-03-13 06:54:06

Willy Vanhaelen

FORMULATEXT is introduced in Excel 2013.
These tips apply to Excel 97 ... 2003.

2016-03-12 10:32:46


Or without Macro fuction just:

where B1 is HYPERLINK.

This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.

Newest Tips

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.