I'm not sure if you will be able to follow along....
Rem Load Option Chain Pricing from Yahoo using the web address
Rem
http://finance.yahoo.com/q/os?m=2008-01
Rem NOTE: Whenever a .refresh is executed, function may be called again from
the beginning, function must be reentrant
Function LoadChains(Stock As String, NextExp As Date, Series As Integer) As
Boolean
Dim ws As Worksheet
Dim conn As String, newconn As String
Dim i As Integer
Static LastCRef(4) As Date
If NextExp <> 0 Then
Set ws = Worksheets("Chain " & Format(Series, "#0"))
If ws.QueryTables.Count <> 0 Then
conn = ws.QueryTables(1).Connection
End If
newconn = "URL;http://finance.yahoo.com/q/os?s=" _
& Stock _
& "&m=" & Format(NextExp, "yyyy") & "-" & Format(NextExp, "m")
If conn <> newconn Then
Do While ws.QueryTables.Count <> 0
ws.QueryTables(1).Delete
Loop
LastCRef(Series) = 0
If ws.Cells(1, 1) <> Empty Then
ws.Range("A1:O50").ClearContents
End If
With ws.QueryTables.Add( _
Connection:=newconn, Destination:=ws.Cells(1, 1))
.BackgroundQuery = False
.EnableRefresh = True
.EnableEditing = True
.FillAdjacentFormulas = True
Rem .Name = "Chain" & Format(Series, "#0") & "_" & Stock
.RefreshOnFileOpen = True
.RefreshStyle = xlOverwriteCells
.SaveData = True
.WebSelectionType = xlSpecifiedTables
.WebTables = "8,12"
End With
End If
If (LastCRef(Series) - LastClose()) < 0 Then ' if close has
occurred since last refresh
ws.QueryTables(1).Refresh (False)
LastCRef(Series) = Now
End If
LoadChains = True
Else ' NextExp = 0 - do nothing
LoadChains = False
End If
End Function