Excel QueryTable会随着时间变慢,直到冻结
我有一个代码,可以运行查询表,将数据导入工作表,然后对数据运行其他代码 我有一个计时器,每90秒运行一次。一切都正常工作,只是随着时间的推移,速度越来越慢。最终(大约12小时后),它完全冻结了。我尝试在代码末尾清除连接,但这并没有解决问题 有什么想法吗Excel QueryTable会随着时间变慢,直到冻结,excel,vba,performance,import,freeze,Excel,Vba,Performance,Import,Freeze,我有一个代码,可以运行查询表,将数据导入工作表,然后对数据运行其他代码 我有一个计时器,每90秒运行一次。一切都正常工作,只是随着时间的推移,速度越来越慢。最终(大约12小时后),它完全冻结了。我尝试在代码末尾清除连接,但这并没有解决问题 有什么想法吗 With ActiveSheet.QueryTables.Add(Connection:= _ "URL;http://www.address.com" _ , Destination:=sh3.Range("$A$1"))
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.address.com" _
, Destination:=sh3.Range("$A$1"))
.Name = "Query"
.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:=False
End With
您是否曾经清理连接,或者每次宏运行时都不断添加?按Ctrl+G,然后键入
?ActiveWorkbook.Connections.Count
。数字是多少?另外,可能是www.address.com
限制您的连接。Dim ii只要ii=ActiveWorkbook.Connections.Count到1步骤-1 ActiveWorkbook.Connections.Item(ii)。删除下一个ii
“我的子步骤末尾有此代码。