我每天都在将我的JSON列表解析为Excel电子表格。它是一个大约400-500个用户信息的列表,每天都在更新。现在因为我不想每天解析相同的列表,我只需要找到添加到JSON中的新对象,并将其与Excel中现有的解析列表进行比较。如果找不到,将添加新对象。这是我的代码:
Private Sub populate_Click()
Dim http As Object, JSON As Object, Item As Variant
Dim i As Integer
Set http = CreateObject("MSXML2.XMLHTTP")
http.Open "GET", "http://controlpanel.verio/rest/reports?errorMessages=null", False
http.send
Dim jsnStr As Object
Set jsnStr = ParseJson(http.responseText)
'Fetching data
i = 3
For Each Item In jsnStr("results")(1)("results")
Dim findy As Variant
findy = Item(4)
Columns("B:B").Select
Set cell = Selection.Find(What:=findy, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext)
If cell Is Nothing Then
'do it something
Sheets(1).Cells(i, 1).Value = Item(3)
Sheets(1).Cells(i, 2).Value = Item(4)
Sheets(1).Cells(i, 5).Value = Item(18)
Sheets(1).Cells(i, 6).Value = Item(6)
Sheets(1).Cells(i, 7).Value = Item(7)
Sheets(1).Cells(i, 8).Value = Item(8)
Sheets(1).Cells(i, 9).Value = Item(5)
Sheets(1).Cells(i, 11).Value = Item(20)
i = i + 1
Else
'do it another thing
End If
Next
Set JSON = Nothing
Set http = Nothing
End Sub
我没有收到任何错误,但没有从excel列表中更改或更新任何内容。
我应该在下面的代码中更正哪些内容?