Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Extracting Hyperlink Information.

Extracting Hyperlink Information

Written by Allen Wyatt (last updated August 7, 2021)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365


4

Cheryl has a worksheet that contains many hyperlinks. The display text for each hyperlink is different than the target for the hyperlink. These hyperlinks are all in column A. Cheryl would like to leave the display text in column A, move the target URL into column B, and delete the hyperlink in column A. What she needs to end up with is the display text in column A, the URL in column B, and no active hyperlinks in the worksheet.

Processing and extracting information from hyperlinks in this manner requires the use of a macro. The following is an example of a flexible macro that examines whatever hyperlinks are in the selected range of cells. If a hyperlink is found, the URL for the hyperlink is entered to the right of the hyperlink and then the hyperlink itself is deleted. This leaves the display text in the cell where the hyperlink used to be.

Sub GetHLInfo()
    Dim c As Range

    For Each c In Selection
        If c.Hyperlinks.Count > 0 Then
            c.Offset(0, 1) = c.Hyperlinks(1).Address
            c.Hyperlinks(1).Delete
        End If
    Next
End Sub

Note:

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 (9898) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. You can find a version of this tip for the older menu interface of Excel here: Extracting Hyperlink Information.

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

Adding Drop-Shadows to Paragraphs

Drop shadows are a style of paragraph border used to enhance the visual impact of a paragraph. They are also a great way ...

Discover More

Getting Rid of 8-Bit ASCII Characters

When working with data created outside of Excel, you may need to check that data to make sure it contains no unwanted ...

Discover More

Preventing the Insertion of Non-Breaking Spaces

When you copy and paste information from the Internet, you may end up with a lot of non-breaking spaces in the pasted ...

Discover More

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!

More ExcelTips (ribbon)

Converting to Hyperlinks in a Shared Workbook

When you enter a URL or e-mail address in a worksheet, Excel usually converts it to a clickable hyperlink. This doesn't ...

Discover More

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

Converting a Range of URLs to Hyperlinks

Converting a single URL into a hyperlink is easy. Converting hundreds or thousands can be much harder if you have to rely ...

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}] (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 two more than 7?

2024-05-01 13:15:24

Sandeep

Thanks Allen.


2024-04-30 09:39:24

Allen

No, not just the first hyperlink. Notice that it is in the middle of a For Each loop, so in this case the loop is stepping through each CELL in the selection. If there is a hyperlink for the cell (and there can only be a maximum of one hyperlink per cell), then the target address is placed one cell to the right and the hyperlink is deleted.

-Allen


2024-04-30 09:33:22

sandeep

Dear Allen / Woolley, what is meant by Hyperlinks(1)? Does the macro not purported to delete only the 1st Hyperlink in the worksheet & none other?


2021-08-08 12:16:53

J. Woolley

You might also be interested in this array function in My Excel Toolbox:
=ListHyperlinks([AllSheets], [SkipHeader])
Anchor, Text, Hyperlink Address, and ScreenTip are listed for each hyperlink in the worksheet or workbook. This function is most useful as a dynamic array in newer versions of Excel. You can also use it like this in older versions of Excel that do not support dynamic arrays:
=SpillArray(ListHyperlinks([AllSheets], [SkipHeader]))
SpillArray will determine and populate the spill range for its array expression argument, simulating a dynamic array.
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.