Hi all. I'm new to VBA. I'm trying to pull text data in aggregate into a cell in excel for each zip code query. I'm sure there are other way to put the data in columns and ways to make the spreadsheet elegant. I just want the data transferred from the site to my spreadsheet and I can go and use tools in excel to get the info I need.
I'm not even sure I have the correct references set up for the .open or the .send. I also don't think I need Javascript, ActiveX, etc to retrieve the data since the api is providing the data in plaintext.
I know that I am going to have a problem with retrieving the zip codes from 00001 to 09999 because the leftmost to the adjoining rightmost zeros will be truncated.
See my miserable attempt at some code below.
Thoughts?
Sub Test()
Dim objHTTP As Object
Dim MyScript As Object
Set objHTTP = CreateObject("MSXML2.XMLHTTP")
For zip = 0 To 99999
Url = "https://godaven.bitbean.com/api/shuls/search-all?nusach=ari&query=" & zip
objHTTP.Open "GET", Url, False
objHTTP.send
Set MyScript = CreateObject("MSScriptControl.ScriptControl")
MyScript.Language = "JScript"
Set RetVal = MyScript.Eval("(" + objHTTP.responsetext + ")")
Sheets(1).Cells(zip, 1).Value = RetVal.USD
Next
End Sub
I'm not even sure I have the correct references set up for the .open or the .send. I also don't think I need Javascript, ActiveX, etc to retrieve the data since the api is providing the data in plaintext.
I know that I am going to have a problem with retrieving the zip codes from 00001 to 09999 because the leftmost to the adjoining rightmost zeros will be truncated.
See my miserable attempt at some code below.
Thoughts?
Sub Test()
Dim objHTTP As Object
Dim MyScript As Object
Set objHTTP = CreateObject("MSXML2.XMLHTTP")
For zip = 0 To 99999
Url = "https://godaven.bitbean.com/api/shuls/search-all?nusach=ari&query=" & zip
objHTTP.Open "GET", Url, False
objHTTP.send
Set MyScript = CreateObject("MSScriptControl.ScriptControl")
MyScript.Language = "JScript"
Set RetVal = MyScript.Eval("(" + objHTTP.responsetext + ")")
Sheets(1).Cells(zip, 1).Value = RetVal.USD
Next
End Sub