运行下面的查询从蒸汽图表抓住一些数据:拖延活动 - VBA
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://steamcharts.com/app/" & games(x), Destination:=Range("A" & lastRowData))
.Name = " & games(x) & "
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlAllTables
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=True
End With
然后,我有其他动作后记像
//Run analysis
我遇到的问题当脚本正确执行时,“分析”部分运行,但无法按预期工作,因为在查询加载时,它可能需要5秒钟才能完成,并且脚本立即执行,而不是等待先前的数据先加载加工。有没有办法延迟后续脚本命令的执行,直到所有数据都加载到电子表格中?
请参阅此链接:https://stackoverflow.com/questions/1544526/how-to-pause-for-specific-amount-of-time-excel-vba – PKatona
@PKatona我对这个解决方案的问题是它指定了一段时间。我真的在问,是否有一种方法可以让excel确认查询仍在运行,并等待数据填充以继续执行脚本。 –