Web query to extract selected data from a web table

opsmgr

New Member
Joined
May 20, 2011
Messages
4
Hi Everyone. I am new to VBA and would like to receive some help regarding this issue.
I am planning to have the actual price of fuel from a website. I am using web query to access the site and retrieve a particular table. In this table table only two rows are relevant ( time and price). rest don't need. how to delete the other rows and have the required rows transpose.
Am planning to have other websites in column A, time in column B and price in Column C. the data should be refreshed periodically.
Also planning to have other website in column A (one under the other) and have same results tabulated.
How can this be done using VBA. Thanks for your valuable support and expertise.:)

the code is as follows:

Public Sub ImportWeb()
Dim qt As QueryTable
Set qt = ActiveSheet.QueryTables.Add(Connection:="URL;http://www.petro-canada.ca/en/locations/4085.aspx?MODE=DTS&ID=59041", _
Destination:=Range("B1"))
With qt
.Name = "Regular, Posted, Self serve"
.WebSelectionType = xlSpecifiedTables
.WebTables = "20" ' Regular table
.WebFormatting = xlWebFormattingNone
.EnableRefresh = True
.RefreshPeriod = 60 'Unit in minutes
.Refresh 'Execute query
End With
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>
Set qt = Nothing
End Sub
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

Forum statistics

Threads
1,224,599
Messages
6,179,828
Members
452,946
Latest member
JoseDavid

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