I have an Excel spreadsheet with columns:
| A | B | C | D |
| Job number | Status | Actual Hrs | % Complete |
1___|____________|________|____________|____________|
2___|____________|________|____________|____________|
I have a macro to obtain the following string from an external web API:
[{
"jobnumber":"123",
"status":"Active",
"actualhrs":"133",
"completion":"94"},
{
"jobnumber":"124",
"status":"Active",
"actualhrs":"13",
"completion":"5"},
...
]
The string will contain hundreds of jobs. I am stumped trying to parse the response as an object in ExcelVBA to then populate rows in a spreadsheet.
Does anyone have any pointers for me? I realise I haven’t got any VBA code shown, but to be honest I’m going in circles.
I have tried Dim data as Object.
For each loop through the object.
2
Answers
You can use VBA-JSON. Here is sample code:
Here is the sample output from above code:
Notes:
Don’t forget to check Installation Guide
JsonConverter.bas
from https://github.com/VBA-tools/VBA-JSONJsonConverter.bas
into the workbookScripting
reference (VBE Tools>Reference, checkMicrosoft Scripting Runtime
)The code may lead to a runtime error if the JSON data is invalid due to the absence of JSON validation.