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

Written by Allen Wyatt (last updated December 8, 2018)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365


2

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.

One way to do the conversion is to use the HYPERLINK function. Put this formula in cell B1 and copy it down as many cells as necessary:

=IF(A1="","",HYPERLINK(IF(LEFT(A1,7)="http://","","http://")&A1))

The result is that column B will contain hyperlinks for everything in column A. The formula isn't terribly robust, as it only deals with the presence or lack of the text "http://", and you may need it to also deal with "https" addresses. It is possible to adjust the formula (i.e., making it more complex), but you may also want to consider using a macro to do the conversions.

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()
    Dim sTemp As String
    Dim sURL As String
    Dim cell As Range

    For Each cell In Selection
        If cell.Value <> "" Then
            sTemp = Left(cell.Value, 7)
            If sTemp = "http://" Or sTemp = "https:/" Then
                sURL = cell.Value
            Else
                sURL = "http://" + cell.Value
            End If
            ActiveSheet.Hyperlinks.Add Anchor:=cell, _
              Address:=sURL, 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://" or "https:/" text, then a prefix of "http://" 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, 2016, 2019, and Excel in Microsoft 365. 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

Copying Comments when Filtering

The advanced filtering feature in Excel allows you to quickly copy unique information from one data list to another. If ...

Discover More

Printing Row Numbers

On-screen Excel displays row numbers that help you easily see what is in each row. If you want to print these row ...

Discover More

Averaging a Non-Contiguous Range

Figuring out how to average data that is in a contiguous range of cells is easy. When the data is spread over a group of ...

Discover More

Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!

More ExcelTips (ribbon)

Hyperlinks in Comments

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

Discover More

Special Characters In Hyperlinks

Do you use special characters (such as the pound sign) in your worksheet names? If so, you could run into problems ...

Discover More

Hyperlink Doesn't Match Cell Contents

When you add a hyperlink to a worksheet, over time and after doing a bunch of editing, what you see in the cell can get ...

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}] (all 7 characters, in the sequence shown) 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 1 + 1?

2018-12-09 09:47:35

Allen

I mentioned using the HYPERLINK function approach at the beginning of the tip, Gayle.

-Allen


2018-12-08 19:52:44

Gayle

Thanks Allen...Is there a reason why you wouldn't use =HYPERLINK(A1) and fill down the column (as long as the URL doesn't exceed 255 characters)?

Gayle


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.