Hi
I have a spreadsheet with several worksheets and I need to run a macro to copy a webpage and paste it into one of the worksheets. This I am doing fine already. What I would like to do is have the macro run automatically if a cell equals a certain value.
The first Worksheet is named "Data" and if the value of cell AE1 = 1 I want the macro to activate. The second worksheet is named "Arg" and it is here that i want the webpage pasted.
Here is the code I have:
Private Sub Worksheet_Calculate()
If [AE3] = 1 Then
Sheets("Arg").Select
Range("G3:BV1000") = "" ' erase previous data
Range("G3").Select
Set IE = CreateObject("InternetExplorer.Application")
With IE
.Visible = True
.Navigate "http://www.google.com" ' should work for any URL
Do Until .ReadyState = 4: DoEvents: Loop
End With
IE.ExecWB 17, 0 '// SelectAll
IE.ExecWB 12, 2 '// Copy selection
ActiveSheet.Paste
Range("G3").Select
IE.Quit
IE.Quit ' just to make sure
Sheets("Data").Select
Range("A1").Select
End If
End Sub
what have I done wrong? Any help would be appreciated.
Doug
Bookmarks