如何让我的数据随着网站更新而更新?



我正在通过 excel 中的按钮在 VBA 中执行以下代码。但是,网站数据正在更新,无论我在按钮单击之间等待多长时间,excel 似乎都不会更新。只有当我关闭 excel 并重新打开时,数据才会更新。如何让我的代码在每次点击时提取实时数据?

Public Sub exceljson()
Dim http As Object
Dim JSON As Object
Dim inst As String
Dim arrInst() As String
Dim arrRatio() As Double
Dim arrBid() As Double
Dim arrAsk() As Double
Dim arrMin() As Double
Dim arrMaxk() As Double
Dim size As Integer
Dim i As Integer, x As Integer
Set http = CreateObject("MSXML2.XMLHTTP")
'Counts the number of cells that are not empty and the values within the list of arguments.
Set myRange = Range("A2:A100")
size = WorksheetFunction.CountA(myRange)
'Sets the array of instruments to the size determined above
'Loops through each row and inputs that instrument name into the array
ReDim arrInst(size)
For i = 1 To size
arrInst(i) = UCase(Range("E1").Offset(i).Value)
Next i
'Get data needed from API for each leg and print in sheet
For i = 1 To UBound(arrInst)
http.Open "GET", ("https://testapp.deribit.com/api/v2/public/ticker?instrument_name=" & arrInst(i)), False
http.Send
Set JSON = ParseJson(http.ResponseText)
Cells(i, 7).Offset(1).Value = JSON("result")("min_price")
Cells(i, 8).Offset(1).Value = JSON("result")("best_bid_price")
Cells(i, 9).Offset(1).Value = JSON("result")("mark_price")
Cells(i, 10).Offset(1).Value = JSON("result")("best_ask_price")
Cells(i, 11).Offset(1).Value = JSON("result")("max_price")
Next i
End Sub

我添加了以下代码:

http.SetRequestHeader "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"

最新更新