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

Elapsed Days as Years, Months and Days

Need to know how many days there are between two dates? It's easy to figure out—unless you need the figure in years, ...

Discover More

Quick Recall of Table Formats

Got a table that you use over and over again? One way you can make quick work of such repetition is to save the table in a ...

Discover More

Turning Off Track Changes Change Bars

Word includes a feature that allows you to track changes made to a document. One of the ways in which Word marks your changes ...

Discover More

Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!

More ExcelTips (ribbon)

Hyperlinks in Comments

Need to add a hyperlink to a comment? It's easy to do by following the steps outlined in this tip.

Discover More

Getting Rid of All Hyperlinks

Need to get rid of all the hyperlinks in a worksheet? It's easy when you use this single-line macro.

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
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 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 8 - 2?

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.