How does one return a specific cell in a web query?

Q

quartz

I have a web query that pulls data to Excel, but it pulls an entire table.
How can I specify that I want only, for example, the data residing in the
third cell in row 3?

Thanks much in advance.

My current code follows:

Dim qts As QueryTables
Dim qt As QueryTable

Set qts = ActiveSheet.QueryTables
Set qt = qts.Add("URL;http://www.pcquote.com/stocks/quote.php?symbol=TR",
Application.Range(ActiveCell.Address))

With qt
.AdjustColumnWidth = True
.BackgroundQuery = False
If .FetchedRowOverflow Then MsgBox "Query too large!"
.FieldNames = True
.PreserveColumnInfo = False
.PreserveFormatting = True
.WebDisableRedirections = False
.WebFormatting = xlWebFormattingAll
.WebPreFormattedTextToColumns = False
.WebSelectionType = xlSpecifiedTables
.WebSingleBlockTextImport = False
.WebTables = "8"
.Refresh
End With
 
D

Don Guillett

I don't think you can do that. You can use data>import external data>edit
query>select the table only>import and after the 1st time then just use this
to refresh instead of re-creating each time which involves deleting lines
first and then deleting names, etc.

ActiveSheet.QueryTables(1).Refresh BackgroundQuery:=False

the copy the desired cell somewhere else or just have it referred to in
another sheet using INDIRECT.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top