我正在使用以下方法从站点下载表格数据。但是每次循环迭代大约需要 1.5 秒。我需要加快速度。请问有什么建议吗?
Sub GetData_Sai()
Dim htm As Object
Dim x As Long, y As Long
Set htm = CreateObject("htmlFile")
Application.ScreenUpdating = False
Row = Sheet2.Cells(Rows.Count, "A").End(xlUp).Row + 1
For p = Range("F1") To Range("F1") + 200
Debug.Print p
Set htm = CreateObject("htmlFile")
With CreateObject("msxml2.xmlhttp")
.Open "GET", <site_url_goes_here>, False
.send
htm.body.innerhtml = .responsetext
End With
With htm.getelementbyid("item")
Sheet2.Cells(Row, 4).Value = p
For x = 1 To .Rows.Length - 1
For y = 0 To .Rows(x).Cells.Length - 1
Sheet2.Cells(Row, y + 1).Value = .Rows(x).Cells(y).innertext
Next y
Row = Row + 1
Next x
End With
Set htm = Nothing
If p Mod 10 = 0 Then ThisWorkbook.Save
Next
Range("F1") = p
Application.ScreenUpdating = True
MsgBox "Done", vbInformation
End Sub