Web Query Excel VBA - TechRepublic
Question
August 21, 2009 at 12:39 PM
lumpydoo

Web Query Excel VBA

by lumpydoo . Updated 16 years, 10 months ago

I want to query the following web page with the following source code. I would like to query for specific

information IE I would like to grab only day, price and finish rather than all of the headers. Is that

possible with a web query, if so how do I do it. ( how do I select individual pieces/elements of the the

table rather than the whole table. At the bottom I included my existing code

html
>

Server Page

With ActiveSheet.QueryTables.Add(Connection:= _

“URL;http://value.page.html” _

, Destination:=Range(“A1”)) ‘not real url

On Error GoTo Handler

.Name = “Value.page.html” ‘not real name

.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 = xlWebFormattingAll

‘ .WebTables = “Term”

.WebSelectionType = xlAllTables

.WebFormatting = xlWebFormattingNone

.WebPreFormattedTextToColumns = True

.WebConsecutiveDelimitersAsOne = True

.WebSingleBlockTextImport = False

.WebDisableDateRecognition = False

.WebDisableRedirections = False

.Refresh BackgroundQuery:=False

End With

Exit Sub

Handler:

MsgBox “Check Network Connection”

Day

Price

Finish

Rate

Value

1

2

3

4

U2009 3.479 8/27/09 6:00 PM 0.015 0.841964901523561 0.046912019463581256 0.011590458342725096 0.010646947807316898 0.022448150410481982
V2009 3.767 9/28/09 6:00 PM 0.015 0.847743512818856 0.1857690456358998 0.04750179459721493 0.013831151776210637 0.027156804811179103
X2009 4.643 10/28/09 6:00 PM 0.015 0.7030416082384954 0.14744789910019174 0.03323864025414547 0.004967201429382784 0.013703106289507327
Z2009 5.41 11/24/09 6:00 PM 0.015 0.5734019689831045 0.1592885903120821 0.027236419761382025 0.005735016984210417 0.022642129840581893
This discussion is locked

All Comments