Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel QueryTable会随着时间变慢,直到冻结_Excel_Vba_Performance_Import_Freeze - Fatal编程技术网

Excel QueryTable会随着时间变慢,直到冻结

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"))

我有一个代码,可以运行查询表,将数据导入工作表,然后对数据运行其他代码

我有一个计时器,每90秒运行一次。一切都正常工作,只是随着时间的推移,速度越来越慢。最终(大约12小时后),它完全冻结了。我尝试在代码末尾清除连接,但这并没有解决问题

有什么想法吗

 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
“我的子步骤末尾有此代码。