Sorry I should of told you, you need to make reference to the Microsoft XML, v3.0 or higher. Tools>References, and scroll down to you find Microsoft XML, v3.0 or higher.
Or you can just copy this code which uses late binding to create the object
Sub testing()
Dim URL As String
Dim XMLHttp As Object
Dim myStr As String
Dim strTemp As Variant
Dim arrValues() As Variant
Dim lonPos As Long, lonEnd As Long
Dim strStart As String, strEnd As String
URL = "http://www.goldsheet.com/gs_new/historic.php?histlink=10cfblog.html"
ActiveSheet.Cells.Clear
Range("A1") = "Please wait processing..." & URL
Set XMLHttp = CreateObject("MSXML2.XMLHttp")
XMLHttp.Open "GET", URL, False
XMLHttp.send
myStr = XMLHttp.responseText
Set XMLHttp = Nothing
strStart = "<p>"
strEnd = "</p>"
ReDim arrValues(1 To 6, 1 To 1)
lonPos = InStr(1, myStr, strStart, vbTextCompare)
Do While lonPos > 0
If lonPos Mod 25 = 0 Then Range("A2") = "Progress: " & Format(lonPos / CLng(Len(myStr)), "0.0 %")
'Move to the end of the start string
'which happens to be the beginning of what we're looking for. :)
lonPos = lonPos + Len(strStart)
'Find the end string starting from where we found the start.
lonEnd = InStr(lonPos, myStr, strEnd, vbTextCompare)
If lonEnd > 0 Then
strTemp = Replace(Mid$(myStr, lonPos, lonEnd - lonPos), " ", "")
strTemp = Replace(strTemp, "<span></span>", "|")
strTemp = Split(strTemp, "|")
For x = 0 To UBound(strTemp)
arrValues(x + 1, UBound(arrValues, 2)) = "'" & strTemp(x)
Next
ReDim Preserve arrValues(1 To 6, 1 To UBound(arrValues, 2) + 1)
End If
lonPos = InStr(lonEnd, myStr, strStart, vbTextCompare)
Loop
arrValues = WorksheetFunction.Transpose(arrValues)
Range("A1").Resize(UBound(arrValues), UBound(arrValues, 2)) = arrValues
Erase arrValues
End Sub
Bookmarks