tomfreeman 发表于 2012-5-7 20:13 
可有样本
下面是我导双色球开奖历史数据的代码,宏1是录的,宏2是根据宏1修改的,导入所有期次数据。不知道这是不是你想要的东西。
Sub 宏1()
'
' 宏1 宏
'
'
With ActiveWorkbook.Connections("连接")
.Name = "连接"
.Description = ""
End With
Range("A1:G24").Select
With Selection.QueryTable
.Connection = "URL;
http://kaijiang.zhcw.com/zhcw/html/ssq/list_1.html"
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
Range("C3").Select
ActiveWorkbook.Connections("连接").Refresh
End Sub
Sub 宏2()
For i = 1 To 67
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;
http://kaijiang.zhcw.com/zhcw/html/ssq/list_" & i & ".html", Destination:=Range( _
"A" & (24 * i - 23)))
.Name = "list_" & i
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
Next i
End Sub