+ Reply to Thread
Results 1 to 2 of 2

Excel web query refresh

Hybrid View

cmb80 Excel web query refresh 01-09-2015, 08:25 AM
cmb80 Re: Excel web query refresh 01-10-2015, 12:12 PM
  1. #1
    Forum Contributor
    Join Date
    04-21-2009
    Location
    England
    MS-Off Ver
    Excel 2016
    Posts
    710

    Excel web query refresh

    Hi all, I would like to create a web Data query from the web in Excel that refreshes every 10 seconds.

    It is for football scores. My current code is below, which runs the query each time - but Ijust wonder if there is a quicker way to do this which will just refresh the existing connection rather than creating a new one?

    Sub Fixtures()
    
    
    Application.ScreenUpdating = False
    ThisWorkbook.Sheets("Sheet1").Range("2:2000").ClearContents
    Application.StatusBar = "Downloading Scores and Fixtures"
    
    'location of my HTTP addresses
    
    URLVal1 = Range("URL!A1")
    URLVal2 = Range("URL!B1")
    URLVal3 = Range("URL!C1")
    
    
    
    
    
    
    Application.CutCopyMode = False
        With Sheets("Sheet1").QueryTables.Add(Connection:= _
    "URL;" & URLVal1, Destination:=Range("Sheet1!$A$2"))
    .FieldNames = True
    .RowNumbers = False
    .FillAdjacentFormulas = False
    .PreserveFormatting = True
    .RefreshOnFileOpen = False
    .BackgroundQuery = True
    .RefreshStyle = xlOverwriteCells
    .SaveData = True
    .AdjustColumnWidth = False
    .RefreshPeriod = 0
    DATA_SELECTION:
    '.WebSelectionType = xlEntirePage
    .WebSelectionType = xlSpecifiedTables
    .WebTables = "3"
    DATA_FORMATTING:
    '.WebFormatting = xlWebFormattingAll
    .WebFormatting = xlWebFormattingNone
    .WebPreFormattedTextToColumns = False
    .WebConsecutiveDelimitersAsOne = True
    .WebSingleBlockTextImport = False
    .WebDisableDateRecognition = True
    .WebDisableRedirections = True
    .Refresh BackgroundQuery:=False
    
    
    End With
    
    Application.CutCopyMode = False
        With Sheets("Sheet1").QueryTables.Add(Connection:= _
    "URL;" & URLVal2, Destination:=Range("Sheet1!$A$82"))
    .FieldNames = True
    .RowNumbers = False
    .FillAdjacentFormulas = False
    .PreserveFormatting = True
    .RefreshOnFileOpen = False
    .BackgroundQuery = True
    .RefreshStyle = xlOverwriteCells
    .SaveData = True
    .AdjustColumnWidth = False
    .RefreshPeriod = 0
    DATA_SELECTION2:
    '.WebSelectionType = xlEntirePage
    .WebSelectionType = xlSpecifiedTables
    .WebTables = "3"
    DATA_FORMATTING2:
    '.WebFormatting = xlWebFormattingAll
    .WebFormatting = xlWebFormattingNone
    .WebPreFormattedTextToColumns = False
    .WebConsecutiveDelimitersAsOne = True
    .WebSingleBlockTextImport = False
    .WebDisableDateRecognition = True
    .WebDisableRedirections = True
    .Refresh BackgroundQuery:=False
    
    
    End With
    
    Application.CutCopyMode = False
        With Sheets("Sheet1").QueryTables.Add(Connection:= _
    "URL;" & URLVal3, Destination:=Range("Sheet1!$A$162"))
    .FieldNames = True
    .RowNumbers = False
    .FillAdjacentFormulas = False
    .PreserveFormatting = True
    .RefreshOnFileOpen = False
    .BackgroundQuery = True
    .RefreshStyle = xlOverwriteCells
    .SaveData = True
    .AdjustColumnWidth = False
    .RefreshPeriod = 0
    DATA_SELECTION3:
    '.WebSelectionType = xlEntirePage
    .WebSelectionType = xlSpecifiedTables
    .WebTables = "3"
    DATA_FORMATTING3:
    '.WebFormatting = xlWebFormattingAll
    .WebFormatting = xlWebFormattingNone
    .WebPreFormattedTextToColumns = False
    .WebConsecutiveDelimitersAsOne = True
    .WebSingleBlockTextImport = False
    .WebDisableDateRecognition = True
    .WebDisableRedirections = True
    .Refresh BackgroundQuery:=False
    
    
    End With
    
    
    For Each qtb In ActiveSheet.QueryTables
    qtb.Delete
    Next
    Application.StatusBar = ""
    Application.OnTime Now + TimeValue("00:00:10"), "Fixtures"
    Application.ScreenUpdating = True
    End Sub

  2. #2
    Forum Contributor
    Join Date
    04-21-2009
    Location
    England
    MS-Off Ver
    Excel 2016
    Posts
    710

    Re: Excel web query refresh

    BUMP! Can anyone assist on how to improve a triple web scrape?

    I would ideally like to be able to start and stop the scrape as and when with a button

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 2
    Last Post: 09-29-2013, 06:15 AM
  2. Replies: 1
    Last Post: 09-28-2013, 07:11 PM
  3. Excel paste link changes after sql query refresh
    By dest in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-08-2008, 03:41 PM
  4. [SOLVED] Query Refresh-Enable Automatic Refresh Dialogue Box
    By Terri in forum Excel General
    Replies: 0
    Last Post: 05-06-2005, 04:06 PM
  5. [SOLVED] Help! Query table refresh hangs excel
    By jbhan in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-29-2005, 05:06 PM

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