Help With Importing Uniform Table Data from Multiple URLs

CloonanCPA

New Member
Joined
Sep 13, 2018
Messages
1
Hello,

I need some help making a macro to extract table data from multiple pages of the same website (see example at https://www(dot)gsaelibrary(dot)gsa...+SERVICES+&+AFFILIATES,+INC.&executeQuery=YES.

I have all the URLs lined up in one row (since the tables I am extracting from the URLS have 2 rows, I used code to insert a blank column between all of my columns with URLs (to give space for 2 rows of data per URL).

When I use the record function for extracting the tables for the first 2 URLS (column A and C), I get the following code:

Sub Macro1()
'
' Macro1 Macro
'
' Keyboard Shortcut: Ctrl+o
'
ActiveCell.FormulaR1C1 = _
"https://www.gsaelibrary.gsa.gov/ElibMain/contractorInfo.do?contractNumber=GS-07F-0361X&contractorName=%27FORE%27+SUPPLY+CO.&executeQuery=YES"
Range("A2").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;https://www.gsaelibrary.gsa.gov/ElibMain/contractorInfo.do?contractNumber=GS-07F-0361X&contractorName=%27FORE%27+SUPPLY+CO.&executeQuery=YES" _
, Destination:=Range("$A$2"))
.CommandType = 0
.Name = _
"contractorInfo.do?contractNumber=GS-07F-0361X&contractorName=%27FORE%27+SUPPLY+CO.&executeQuery=YES"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "13"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
Range("C1").Select
ActiveCell.FormulaR1C1 = _
"https://www.gsaelibrary.gsa.gov/ElibMain/contractorInfo.do?contractNumber=GS-07F-0386N&contractorName=%27JM%27+TEMPORARY+SERVICES+%26+AFFILIATES%2C+INC.&executeQuery=YES"
Range("C2").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;https://www.gsaelibrary.gsa.gov/ElibMain/contractorInfo.do?contractNumber=GS-07F-0386N&contractorName=%27JM%27+TEMPORARY+SERVICES+%26+AFFILIATES%2C+INC.&executeQuery=YES" _
, Destination:=Range("$C$2"))
.CommandType = 0
.Name = _
"contractorInfo.do?contractNumber=GS-07F-0386N&contractorName=%27JM%27+TEMPORARY+SERVICES+%26+AFFILIATES%2C+INC.&executeQuery=YES"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "13"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub

Can somebody help me out on here or via email at wcloonan@cloonancpa(dot)com. I would be greatly appreciative.

Thank you so much!
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Forum statistics

Threads
1,223,910
Messages
6,175,318
Members
452,634
Latest member
cpostell

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