希望有人可以帮助我解决代码错误。我正在尝试使用API获得股票qoute。但是我在这部分上出错了。我=杰森(1)(“金额”)。错误是运行时错误'13':类型不匹配下面是完整的代码。 在此先感谢
Sub Getstockqoute()
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Dim wb As Workbook
Dim ws As Worksheet
Dim rng As Range
Dim symbol As String
Dim n As Integer
Dim lastrow As Long
Set wb = ActiveWorkbook
Set ws = Sheets("Sheet1")
ws.Activate
'Last row find
lastrow = ws.Cells(Rows.Count, "A").End(xlUp).Row
Set rng = ws.Range("A4:A" & lastrow)
'Clear Prior Prices
ws.Range("B4:B" & lastrow).ClearContents
n = 4
'Get Symbols list
For Each x In rng
symbol = x
Set myrequest = CreateObject("WinHttp.WinHttpRequest.5.1")
myrequest.Open "Get", "http://phisix-api.appspot.com/stocks/" & symbol & ".json"
myrequest.Send
Dim Json As Object
Set Json = JsonConverter.ParseJson(myrequest.ResponseText)
i = Json(1)("amount")
ws.Range(Cells(n, 2), Cells(n, 2)) = i
n = n + 1
ws.Columns("B").AutoFit
MsgBox ("Data is downloaded.")
ws.Range("B4:B" & lastrow).HorizontalAlignment = xlGeneral
ws.Range("B4:B" & lastrow).NumberFormat = "#,##0.00"
Next x
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub'