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.

Converting a Range of URLs to Hyperlinks

by Allen Wyatt
(last updated October 18, 2016)

8

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.

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

Problem Printing Quotation Marks

If you go to print a document and find out that your quotation marks aren't printing properly, there could be a number of ...

Discover More

Saving in a Macro Using a Desired File Name

Need to save a new document, from within a macro, to a specific file name? If you use the Record Macro capabilities of Word, ...

Discover More

Determining the Day of the Week

Need to know what the day of the week is? Sheets provides a handy function that can return a numeric value that represents ...

Discover More

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!

More ExcelTips (ribbon)

Specifying a Browser in a Hyperlink

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

Automatic Text in an E-mail

When creating an e-mail address hyperlink using the Insert Hyperlink dialog box, Excel allows you to enter a subject for the ...

Discover More

Links to Hyperlinks

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
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}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 8Mpixels. 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 0 + 7?

2016-11-07 12:04:08

TGOE

Good morning -

I have a similar problem, but my reference columns contains blanks.. how would i convert that to a hyperlink.

cell text:
http://www.xyz.com/hello world/

what i would like the link to look like:
http://www.xyz.com/hello%20world/


2013-07-22 21:19:36

Mike

Thanks for the suggestions, but I think I've discovered a way that appears even easier than that suggested either here or on "getting rid of hyperlinks without a macro" tips.

This assumes that all cells that could contain hyperlinks do so. If some do & some don't, then skip step 1.

1. Highlight the first cell containing a hyperlink, right-click and select "remove hyperlink".
2. Still on a deactivated hyperlink, click on Home tab, double-click on Format painter icon.
3. Select each cell, group of cells, column or row you want to remove hyperlinks from in turn.
4. When you've finished, press escape to end Format painter.


2013-07-22 08:23:51

awyatt

Mike,

Using the search box at the upper-right of this page, enter "remove hyperlinks" (without the quote marks) and you'll find several ways to get rid of lots of hyperlinks at once.

-Allen


2013-07-22 08:00:49

Bryan

For something this trivial either way, the determining factor should be how often you need to do the action. If you are adding hyperlinks daily, then use the macro (saved to your Personal.xlsb). If you are only doing it once, then use the formula.

When using the formula, if you don't want the extra column, then copy it and select Paste Special -> Values. You can then delete the extra column.


2013-07-22 07:07:18

Andrew

Mike - you can select a group of cells and right click and then click on Remove Hyperlinks (I've tried this in Excel 2010 and it works).
Colin / Barouh - I suppose sometimes you do not want to create extra columns in your data when a simple function/macro will solve the issue.


2013-07-22 04:36:26

Barouh

As far as I can see, the same result can be received with pretty simple formula - using HYPERLINK (plus CONCATENATE and SUBSTITUTE if necessary)


2013-07-20 23:55:26

Colin

It is not necessary to build a macro to solve this problem. Excel's HYPERLINK function is designed for this very purpose and with the same logic prescribed for the macro can be used in a formula such as the following and copied to each cell in a column adjacent to the text entries:
=IF(A1="","",HYPERLINK(IF(LEFT(A1,7)="http://","","http://")&A1))


2013-07-20 07:16:02

Mike

I've not had the need for this tip yet, but I have had the need to remove a batch of hyperlinks, particularly for email addresses. I know I can right-click on an individual cell and select "remove hyperlink", but this option is not available if you select a number of cells containing hyperlinks.

Any suggestions?


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.