Answer the question
In order to leave comments, you need to log in
Parsing JSON VBA?
First time on this site. Not a developer, but interested in VBA. Please help. I want to parse JSON from a URL, but I get a Run-time Error 13" Type Mismatch with Sheets(1).Cells(i, 1).Value = Item("barcode") I can't do it myself. Below is json and VBA itself. Thanks
{
"barcode": "",
"devCode": "1",
"height": 0,
"itemType": 0,
"length": 0,
"weight": 0,
"width": 0
}
Public Sub exceljson()
Dim http As Object, JSON As Object, i As Integer
Set http = CreateObject("MSXML2.XMLHTTP")
http.Open "GET", "http://******", False
http.Send
Set JSON = ParseJson(http.responseText)
i = 2
For Each Item In JSON
Sheets(1).Cells(i, 1).Value = Item("barcode")
Sheets(1).Cells(i, 2).Value = Item("devCode")
Sheets(1).Cells(i, 3).Value = Item("height")
Sheets(1).Cells(i, 4).Value = Item("itemType")
Sheets(1).Cells(i, 5).Value = Item("lenght")
Sheets(1).Cells(i, 6).Value = Item("weight")
Sheets(1).Cells(i, 7).Value = Item("width")
i = i + 1
Next
MsgBox ("complete")
End Sub
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question