Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Office 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: Specifying a Browser in a Hyperlink.
by Allen Wyatt
(last updated June 1, 2021)
Laura wants to include a hyperlink in a worksheet. However, she would like the hyperlink to "force" the target of the URL to be displayed in a particular browser. For instance, she would like the hyperlink to somehow specify that the target be opened in Internet Explorer.
There is no way to do this within Excel; a hyperlink in a worksheet, when clicked, relies on whatever the default browser is on the system being used. There is a workaround that you can try, however: You could create a macro that actually opens a target address using a specific browser.
For example, consider the following macro. It automatically opens an instance of Internet Explorer and opens a website in that browser:
Sub LaunchIE() Dim IE As Object Set IE = CreateObject("InternetExplorer.Application") IE.navigate "http://excel.tips.net/" IE.Visible = True Set IE = Nothing End Sub
The macro could easily be assigned to a shortcut key. It isn't terribly flexible, however, when it comes to which browser is being used (it is always Internet Explorer) and which site is displayed (it is always the ExcelTips site). You can make it a bit more flexible in this manner:
Sub showURL(browser As String, URL As String) Dim pPath As String Dim bPath As String 'Use this to resolve the correct program file path 'it is different on 32-bit and 64-bit systems pPath = Environ("ProgramFiles") If browser = "Firefox" Then bPath = pPath & "\Mozilla Firefox\Firefox.exe" ElseIf browser = "IE" Then bPath = pPath & "\Internet Explorer\iexplore.exe" Else Exit Sub End If Call Shell(bPath & " " & URL, vbNormalFocus) End Sub
Sub Testing() Call showURL("Firefox", "http://www.tips.net") Call showURL("IE", "http://excel.tips.net") End Sub
Note that the main routine—showURL, the one that does all the work—can work with either Internet Explorer or Firefox. The Testing routine shows how to launch the browsers; all you need to do is specify which browser you want and what URL you want to open in that browser.
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (9836) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Office 365. You can find a version of this tip for the older menu interface of Excel here: Specifying a Browser in a Hyperlink.
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!
Besides saving a worksheet as a complete Web page, you can also save smaller portions of your data to an existing Web ...Discover More
Excel provides a good number of worksheet functions that can help you pick apart text strings in various ways. In this ...Discover More
Hyperlinks to many types of Web sites rely on passing parameters in the URL. Knowing this, you can construct a dynamic ...Discover More
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
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.