每一个期货品种一张表,按照时间顺序排列,数据在2011年以前是全部一起下载的。只有在以后才是分类的。
先建一个空白工作表,按ALT+F11,点击sheet1,插入模块(这样数据就能在同一个工作薄中),然后复制以下代码:
Sub AAA()
Dim A, B, C As Date, i As Integer, D, E As Variant
On Error Resume Next
A = #5/9/2005#
B = #12/31/2009#
E = DateDiff("D", A, B)
For i = 0 To E
C = A + i
D = Format(C, "YYYYMMDD")
Worksheets.Add(before:=Worksheets(1)).Name = D
With ActiveSheet.QueryTables.Add(Connection:="URL;http://www.czce.com.cn/portal/exchange/jyxx/hq/hq" & D & ".html", Destination:=Range("A1"))
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SaveData = True
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "3"
.Refresh BackgroundQuery:=False
End With
Next i
End Sub
运行就可以了,至于2011年以后的分类数据下载问题,你改改Connection:="
即可。这样的工作很简单,至此,问题已经解决啦。


雷达卡



京公网安备 11010802022788号







