Command button

Exceldc7

New Member
Joined
Mar 14, 2013
Messages
10
Can you have a command button in an excel that will open up a web page?
if so what kind of code do I use?
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Here's a couple of ways to do that:
Code:
Sub FollowHyperLink()

   Range("A1").Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True


End Sub




Sub NavigateToURL()


Dim IE As New InternetExplorer
Dim URL As String


URL = "www.mrexcel.com"


With IE
    .Navigate (URL)
    .Visible = True
End With


End Sub


The first one opens a hyperlink from your workbook. Supereasy to use if you have the hyperlink on your workbook (if the hyperlink is not located in the active sheet make sure to add the sheet name to the code as well).

The next one opens a new Internet Explorer and navigates to the given URL. Make sure you have selected the Microsoft Internet Controls reference (Tools / References in the VB Editor) when using this one.
 
Upvote 0
Im having issues with this. I couldn't find the Microsoft Internet option. I'm will to do it either way. Do I have to remove the command button part and put sub hyperlink part. It actually looks like the code is find. Just doesn't go to the web page
 
Upvote 0
Worked for me.
At the VBE / Tools / References window should be a line called Microsoft Internet Controls. Check it and run the Navigate macro.
If you do not get a compile error, this means the reference is correct.
If a IE window does not open, you have some other problem...
 
Upvote 0

Forum statistics

Threads
1,214,817
Messages
6,121,717
Members
449,050
Latest member
MiguekHeka

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top