Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Opening Sites in a Browser.

Opening Sites in a Browser

Written by Allen Wyatt (last updated July 21, 2018)
This tip applies to Excel 97, 2000, 2002, and 2003


Steve has a range of cells (A1:A10) that contain website addresses—for example, www.example.com. He wonders if it is possible, within a macro, to open each of these addresses in a browser all at once in separate browser tabs.

There are a couple of ways you can approach this task, and which one you choose depends largely on the nature of the data in your worksheet. If the cells contain active hyperlinks (ones that if you click on them, the address is opened in a browser), then you can use a rather simple macro:

Sub FollowHyperlinks1()
    Dim MyRange As Range
    Dim hl As Hyperlink

    On Error Resume Next
    Set MyRange = Range("A1:A10")
    For Each hl In MyRange.Hyperlinks
        hl.Follow
    Next hl
End Sub

The macro simply looks at all the hyperlinks in the range of A1:A10 and uses the Follow method to open each of them in your default browser. Because of the way in which your operating system transfers information from Excel to your browser, it is a good idea to have your browser open before you run the macro. The reason for this is because, in testing, we found that you may actually end up with two instances of the browser open, with some addresses open in one instance and some in the other. This apparently occurs because of the delay in opening the first instance of the browser. If the browser is open before the macro is run, then there is no delay and each address opens in a different tab of the same browser instance.

If the addresses in your worksheet may not be active hyperlinks, then you can't rely upon using the Hyperlinks collection for the range. Instead, you need to look at the value of each cell in the range:

Sub FollowHyperlinks2()
    Dim MyRange As Range
    Dim cell As Range
    Dim sTemp As String

    On Error Resume Next
    Set MyRange = Range("A1:A10")
    For Each cell In MyRange
        sTemp = cell.Value
        ThisWorkbook.FollowHyperlink _
          Address:=sTemp
    Next cell
End Sub

This approach uses the FollowHyperlink method to load the address in the sTemp variable. In this case, it doesn't matter whether the contents of the cells are active hyperlinks or not; the code still tries to open them in a browser.

Finally, if your data may not contain fully qualified addresses, then you'll need to use a different approach, still. For instance, Steve mentioned having addresses such as www.example.com in the worksheet, but such an address will not work with the examples so far. If your data is missing http:// at the beginning (or some variant, such as https://), then the code won't open the address in the browser. In your data has this peculiarity, then a slight modification to the macro is in order:

Sub FollowHyperlinks3()
    Dim MyRange As Range
    Dim cell As Range
    Dim sTemp As String

    On Error Resume Next
    Set MyRange = Range("A1:A10")
    For Each cell In MyRange
        sTemp = cell.Value
        If InStr(sTemp, "://") = 0 Then
            sTemp = "http://" & sTemp
        End If
        ThisWorkbook.FollowHyperlink _
          Address:=sTemp
    Next cell
End Sub

Note that this example examines the contents of sTemp to see if it has the characters "://" within it. If not, then the prefix http:// is added to the cell contents and Excel tries to use the FollowHyperlink method to open the modified address.

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 (11413) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Opening Sites in a Browser.

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

Adjusting Comment Printouts

Need to print out comments, but in a way that you control what is included in the printout? Here's a way you can extract ...

Discover More

Inserting a File Name without an Extension

Sometimes you might like to insert a file name into your document without including the file extension. The FILENAME ...

Discover More

Monitoring the Number of Formats Defined

The number of formats used in a workbook can become a problem if you run up against the limit Microsoft hard-coded into ...

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 (menu)

Dynamic Hyperlinks in Excel

Hyperlinks to many types of Web sites rely on passing parameters in the URL. Knowing this, you can construct a dynamic ...

Discover More

Hyperlinks in Shared Workbooks

Inserting a hyperlink into a workbook that is shared with others is not possible in Excel. Here's what you can do about it.

Discover More

Jumping to Text in Worksheet from an Index

In putting together a workbook, you may develop a worksheet that acts as an index, to contain links that lead to other ...

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 two more than 7?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon 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.