-
-
Notifications
You must be signed in to change notification settings - Fork 504
Open
Description
Better version that reads the object properties and makes into a table with headers:
Option Explicit
Public Sub IterateOverACollection()
Dim jsonString As String
jsonString = "[{""row"":1, ""a"":""0007"", ""b"":""Blue"", ""c"":""2008""}, {""row"":2, ""a"":null, ""b"":"""", ""c"":""1709""}]"
Dim myCollection As Collection
Set myCollection = ParseJson(jsonString)
Dim myDictionary As Dictionary
Dim i As Long, j As Long
Dim StartCell As Range
Set StartCell = ActiveSheet.Range("A1")
Set myDictionary = myCollection(1)
For j = 1 To myDictionary.Count
StartCell.Offset(0, j - 1) = myDictionary.Keys(j - 1)
StartCell.Offset(0, j - 1).Font.Bold = True
Next j
For i = 1 To myCollection.Count
Set myDictionary = myCollection(i)
For j = 1 To myDictionary.Count
StartCell.Offset(i, j - 1) = myDictionary.Items(j - 1)
Next j
Next i
End Sub
Originally posted by @zgrose in #329 (comment)
Metadata
Metadata
Assignees
Labels
No labels
