Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, and 2013. 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: Converting a Range of URLs to Hyperlinks.
by Allen Wyatt
(last updated October 18, 2016)
John has a workbook that has well over a thousands URLs in it, all in column A. These are not hyperlinks; they are straight text of individual URLs. John wants to convert the URLs to active hyperlinks, but doing the conversion individually is extremely tedious, especially for that many URLs.
As is the case with most tedium in Excel, the solution is to use a macro to do the conversion. To be effective, the macro would need to step through each cell in a selected range and, if the cell is not blank, convert the contents to a hyperlink. The following will do the trick:
Sub URL_List() For Each cell In Selection If cell.Value <> "" Then If Left(cell.Value, 7) = "http://" Then URL = cell.Value Else URL = "http://" + cell.Value End If ActiveSheet.Hyperlinks.Add Anchor:=cell, _ Address:=URL, TextToDisplay:=cell.Value End If Next cell End Sub
The macro is not foolproof; it assumes that if a cell contains anything at all it is a valid URL. What it does is to check the cell contents and, if the contents aren't prefaced by the "http://" text, then it is added. The hyperlink is then created based on the cell contents.
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (5825) applies to Microsoft Excel 2007, 2010, and 2013. You can find a version of this tip for the older menu interface of Excel here: Converting a Range of URLs to Hyperlinks.
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!
Excel allows you to easily add hyperlinks to a worksheet. Click on it, and the target of the link is opened in a browser ...Discover More
When creating an e-mail address hyperlink using the Insert Hyperlink dialog box, Excel allows you to enter a subject for the ...Discover More
Hyperlinks in a worksheet can be helpful or essential, depending on the nature of your data. If you create a link to a ...Discover More
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.