Results 1 to 5 of 5

Run Macro If Cell Value = 1

Threaded View

  1. #1
    Registered User
    Join Date
    01-23-2009
    Location
    australia
    MS-Off Ver
    Excel 2007
    Posts
    50

    Run Macro If Cell Value = 1

    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
    Last edited by boohah; 05-25-2010 at 09:50 AM. Reason: Code Tags

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1