Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, and 2016. 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 June 8, 2018)

8

John has a workbook that has well over a thousand 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.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (5825) applies to Microsoft Excel 2007, 2010, 2013, and 2016. 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

Entering Numbers in Excel

Enter information into a cell, and Excel needs to figure out what type of information it is. Here's how Excel interprets ...

Discover More

Comments in Endnotes

Able to add comments everywhere, except in endnotes? This seems to be a limitation in Word, but here are some ways to ...

Discover More

Entered Values are Divided by 100

Enter a value into a cell and "poof!" it is automatically divided by 100. What's going on, and how can you fix it so that ...

Discover More

Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!

More ExcelTips (ribbon)

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

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

Pulling Apart a URL

Excel provides a good number of worksheet functions that can help you pick apart text strings in various ways. In this ...

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 seven less 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.