Written by Allen Wyatt (last updated August 7, 2021)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and 2021
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:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (9898) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and 2021. You can find a version of this tip for the older menu interface of Excel here: Extracting Hyperlink Information.
Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!
Hyperlinks to many types of Web sites rely on passing parameters in the URL. Knowing this, you can construct a dynamic ...
Discover MoreBesides saving a worksheet as a complete Web page, you can also save smaller portions of your data to an existing Web ...
Discover MoreWhen creating an e-mail address hyperlink using the Insert Hyperlink dialog box, Excel allows you to enter a subject for ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
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/
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.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2025 Sharon Parq Associates, Inc.
Comments