How's this?
Sub GetData(dDate As Date)
Dim oXML As Object
Dim oNodes As Object, oNode As Object, oChildNode As Object
Dim x As Long, y As Long
Dim sNodeName, vData, vNodeNames
vNodeNames = Array("SD", "SP", "SSP", "SBP", "BD", "PDC", _
"NIV", "SPPA", "BPPA", "OV", "BV", "TOV", _
"TBV", "ASV", "ABV", "TASV", "TABV", "RP", "RPRV")
With CreateObject("MSXML2.DOMDocument")
.async = False
.Load "http://www.bmreports.com/bsp/additional/soapfunctions.php?element=SYSPRICE&dT=" & Format(dDate, "yyyy-mm-dd")
Set oNodes = .getElementsByTagName("ELEMENT")
End With
ReDim vData(1 To oNodes.Length, 1 To 19)
x = 1: y = 1
For Each oNode In oNodes
For Each sNodeName In vNodeNames
Set oChildNode = oNode.SelectSingleNode(sNodeName)
If Not oChildNode Is Nothing Then
vData(x, y) = oChildNode.Text
End If
y = y + 1
Next sNodeName
y = 1
x = x + 1
Next oNode
With Sheets("output")
.Range("a1").Resize(, UBound(vNodeNames) + 1).Value = vNodeNames
.Range("a2").Resize(UBound(vData), UBound(vData, 2)).Value = vData
End With
End Sub
Sub test()
GetData #1/1/2013#
End Sub
You'll need to change the name of the output sheet accordingly
Bookmarks