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

Determining an Integer Value

When creating macros, you often need to process numbers in various ways. VBA allows you to convert a numeric value to an ...

Discover More

Understanding Mirror Margins

Rather than have the margins of your documents always be the same, you can use what Word calls "mirror margins." Here's how ...

Discover More

Finding and Replacing Error Values

Want to get rid of error values in your worksheet? There are a couple of ways you can approach this particular challenge, as ...

Discover More

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!

MORE EXCELTIPS (RIBBON)

Adding Excel Information to a Web Page

Besides saving a worksheet as a complete Web page, you can also save smaller portions of your data to an existing Web page. ...

Discover More

Adding a ScreenTip

If you want people to know something about a hyperlink you added to your worksheet, one way to help them is to use ...

Discover More

Pasting a Hyperlink

Need a quick link within a document to some external data? You can paste information so that Excel treats it just like 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 for this tip:

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

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.

Links and Sharing