Executing multiple web queries?

stringer47

New Member
Joined
Feb 26, 2020
Messages
6
Office Version
  1. 2019
Platform
  1. MacOS
Hi,





I'm using excel for Mac 15.23. I have hundreds of .txt files that are serving as web queries to bring data into excel.





Currently, I'm executing each query individually (Data > Get External Data > Run Saved Query....) then repeating with the next query, and the next one, and the next one....





Obviously, this procedure is relatively time consuming and I'm wondering if there is a way to execute MANY or even ALL of my queries at once instead of doing them individually as described.





Appreciate the help.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
It would, yes.. But what I'm asking about is initially setting up my workbook with the queries.

I really don't have a need to have the data refresh, so perhaps I'm going about this the wrong way. I'm trying to import weekly football statistics from specific dates.

Instead of copying and pasting every week into excel, I thought this may be faster.

Maybe my question should be, is there a better way to pull data off of web pages?

Thanks for the reply.
 
Upvote 0
Is it a matter of changing the URL each week or are these all on one table?

It would be good to see some examples and what you are trying to achieve one week vs the next

So URL's and values.
 
Upvote 0
Ultimately, I'm trying to generate a data table that consists of about 30 statistical categories for each team, for each week of the season, from 2012-current. This data table will serve as my source for a vlookup function to bring the stats to the correct team/week/season in a schedule workbook. Here are the URLs for two weeks of one stat category I wish to use:



Thanks for the input, agian.
 
Upvote 0
I haven't done this kind of thing before, however.

I'd consider something like this, doing a season at a time:

**Note it looks for columns 2012 and 2011 in the below Queries.Add, this will need to change through the seasons I assume.

VBA Code:
Sub Macro1()

Dim mydate As Date
Dim DateStr As String
Dim counter As Long

counter = 50  '''just a random number, cannot be duplicated through the book
mydate = DateValue("Sep 4, 2012")  '''Starting date of imports


Do Until mydate > DateValue("Oct 4, 2012")  '''end date
DateStr = Format(mydate, "yyyy-mm-dd")


    Sheets.Add After:=ActiveSheet
    ActiveWorkbook.Queries.Add Name:="Table " & counter & "", Formula:= _
        "let" & Chr(13) & "" & Chr(10) & "    Source = Web.Page(Web.Contents(""https://www.teamrankings.com/college-football/stat/third-downs-per-game?date=" & DateStr & """))," & Chr(13) & "" & Chr(10) & "    Data0 = Source{0}[Data]," & Chr(13) & "" & Chr(10) & "    #""Changed Type"" = Table.TransformColumnTypes(Data0,{{""Rank"", Int64.Type}, {""Team"", type text}, {""2012"", type number}, {""Last 3"", type number}, {""Last 1"", Int64.Type}, {""Home"", type tex" & _
        "t}, {""Away"", type text}, {""2011"", type text}})" & Chr(13) & "" & Chr(10) & "in" & Chr(13) & "" & Chr(10) & "    #""Changed Type"""
    ActiveWorkbook.Worksheets.Add
    With ActiveSheet.ListObjects.Add(SourceType:=0, Source:= _
        "OLEDB;Provider=Microsoft.Mashup.OleDb.1;Data Source=$Workbook$;Location=""Table " & counter & """;Extended Properties=""""" _
        , Destination:=Range("$A$1")).QueryTable
        .CommandType = xlCmdSql
        .CommandText = Array("SELECT * FROM [Table " & counter & "]")
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .PreserveColumnInfo = True
        '.ListObject.DisplayName = "Table_0"
        .Refresh BackgroundQuery:=False
    End With

ActiveSheet.Name = DateStr
mydate = mydate + 7  '''go to next week
counter = counter + 1
Loop
  

End Sub
 
Upvote 0
Wow.. So, first... Thanks for the help. Second, pardon my ignorance, as I obviously have lots to learn. That being said, what do I do with what you wrote!? Is it a file I run in excel, or do I type that directly into the workbook??

What is this "code" called? I'd like to learn more about it.

Again, sorry for the newbie questions and thanks for your time!
 
Upvote 0
I gave it a shot and I get a 438 error. Thanks... really interesting stuff, hopefully I can pick some of this up!
 
Upvote 0

Forum statistics

Threads
1,215,676
Messages
6,126,168
Members
449,296
Latest member
tinneytwin

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