Hi,
My code below fetches a list of addresses from a Postcode via an API call
Currently it spits out the results to column A and works well.
What I want is for the results to populate a combobox instead.
I have tried replacing
with
but that doesn't work probably because I need to somehow split myData.line_1 from the rest of the results?
myData.line_1 is the only list of values I want from the XML source
thanks
My code below fetches a list of addresses from a Postcode via an API call
Currently it spits out the results to column A and works well.
What I want is for the results to populate a combobox instead.
VBA Code:
Private Sub CommandButton1_Click()
Dim objHTTP As Object
Dim MyScript As Object
Dim i As Long
Dim myData As Object
Dim postC, urlX As String
Set MyScript = CreateObject("MSScriptControl.ScriptControl")
MyScript.Language = "JScript"
ComboBox4.Enabled = True
postC = TextBox10.Value
urlX = "https://api.ideal-postcodes.co.uk/v1/postcodes/" & postC & "?api_key=iddqd"
URL = urlX
Set objHTTP = CreateObject("MSXML2.XMLHTTP")
objHTTP.Open "GET", URL, False
objHTTP.send
Set RetVal = MyScript.Eval("(" + objHTTP.responseText + ")")
objHTTP.abort
i = 2
For Each myData In MyList
Cells(i, 1).Value = myData.line_1
i = i + 1
Next
Set MyList = Nothing
Set objHTTP = Nothing
Set MyScript = Nothing
End Sub
I have tried replacing
Code:
For Each myData In MyList
Cells(i, 1).Value = myData.line_1
i = i + 1
Next
with
Code:
For Each myData In MyList
ComboBox4.AddItem
Next
but that doesn't work probably because I need to somehow split myData.line_1 from the rest of the results?
myData.line_1 is the only list of values I want from the XML source
thanks