我可以从 excel 电子表格运行 Web 查询,但是当我输入 VBA 时,它没有数据。这是一行数据的样子,日期都在一列中。日期前面有一个我想删除的报价,但如果必须,我会在 VBA 中进行。
Monday, February 17, 2014 5 1 1
这是代码段:
DownloadURL = "http://www.wilottery.com/lottogames/pick3Allhistory.aspx/pick3history.xls"
On Error Resume Next
With Ws1.QueryTables.Add(Connection:=DownloadURL, Destination:=Ws1.Range("$A$1"))
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "20"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
ActiveWindow.SmallScroll Down:=-12
Ws1.Range("A1").TextToColumns Destination:=Ws1.Range("A1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=True, Space:=False, Other:=False, _
FieldInfo:=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1), Array(8, 1), Array(9, 1), Array(10, 1), Array(11, 1), Array(12, 1), Array(13, 1), Array(14, 1))