Navigate to Webpage based on IF

TiTuS

Board Regular
Joined
Nov 10, 2004
Messages
238
Hi there,

If a1=True i want to navigate to a webpage how can this be done?

Thanks,

Tim
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Navigate to what web page? In what? Excel? Internet Explorer? What are you trying to accomplish?
 
Upvote 0
Sorry,

I Want to navigate to a webpage in IE prefibly an already open instance

example if the webpage thats open is Google I want it to navigate away to Yahoo
 
Last edited:
Upvote 0
Maybe Vb(a) sitting in the backround that looks for This condition then navigates to the correct web page
 
Upvote 0
Sorry,

I Want to navigate to a webpage in IE prefibly an already open instance

example if the webpage thats open is Google I want it to navigate away to Yahoo
This should get you started. This finds existing IE windows and navigates each to yahoo.com:
Code:
Public Sub Find_IE_Windows()

    Dim Shell As Object
    Dim IE As Object
    
    Set Shell = CreateObject("Shell.Application")
    
    For Each IE In Shell.Windows
        If TypeName(IE.Document) = "HTMLDocument" Then
            MsgBox "Internet Explorer window found:" & vbCrLf & _
                "LocationURL=" & IE.LocationURL & vbCrLf & _
                "LocationName=" & IE.LocationName
            IE.Navigate "www.yahoo.com"
        End If
    Next

End Sub
You could call this from a UDF or Worksheet_Change event or similar, as required.
 
Upvote 0
Thanks for that John,

Could this be triggered by the following, this is a bit of code i haven't been able to get to work so it may need altering..

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target = "d3" Then
If Target.Value = "Navigate to my Web Page" Then
MyMacro
End If
End If
End Sub


As far as i understand this method I am saying if D3 = "Navigate to my Web Page" Then MyMacro will be called...

This doesnt work so I know i have it wrong somewhere...

In advance thanks a heap!

Ps I guess where mymacro is i could just execute that code you sent? instead of another module
 
Last edited:
Upvote 0
Ok I have the following..


Private Sub Worksheet_Change (ByVal Target As Range)
If Target.Row = 3 And Target.Column = 4 And Target.Count = 1 Then
If Target.Value = "Navigate to my Web Page" Then
Find_IE_Windows
End If
End If
End Sub

Public Sub Find_IE_Windows()

Dim Shell As Object
Dim IE As Object

Set Shell = CreateObject("Shell.Application")

For Each IE In Shell.Windows
If TypeName(IE.Document) = "HTMLDocument" Then
IE.Navigate "www.yahoo.com"
End If
Next

End Sub


Both sections of this code work perfectly except that the cell It is looking for here

If Target.Row = 3 And Target.Column = 4 And Target.Count = 1 Then
If Target.Value = "Navigate to my Web Page" Then

will change based on a formulae...

Aparently Worksheet_Change Doesn't like working of a recalculate, it only likes working if the cell is manually changed and then moved away from..

How can i get the above code to work if the cell is updated via a formulae (external source)
 
Last edited:
Upvote 0
Worksheet_Calculate must be used instead of Worksheet_Change if D3 is the result of a formula. So something like this:
Code:
Private Sub Worksheet_Calculate()
    If Range("D3").Value = "Navigate to my Web Page" Then
        Find_IE_Windows
    End If
End Sub
This would then work if D3 contains a formula, for example =D5, and D5 contains the text "Navigate to my Web Page".
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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