I'm working with the SmartyStreets API and I'm trying to test the response to see if there is a value in the "delivery_line_2" field. I keep getting a variable undefined error in VBA for Excel when trying to run the code. Anyone have a suggestion for the best way to do this? I'm using the following code to try to access:
Dim candidates, candidate, components, metadata, analysis As MSXML2.IXMLDOMNode
Set candidates = xmlDoc.DocumentElement
For Each candidate In candidates.ChildNodes
Set components = candidate.SelectSingleNode("components")
Set metadata = candidate.SelectSingleNode("metadata")
Set analysis = candidate.SelectSingleNode("analysis")
Cells(RowIndex, DPVColumn).Value = analysis.SelectSingleNode("dpv_match_code").nodeTypedValue
Cells(RowIndex, DPVColumn + 1).Value = components.SelectSingleNode("zipcode").nodeTypedValue & "-" & components.SelectSingleNode("plus4_code").nodeTypedValue
Cells(RowIndex, DPVColumn + 2).Value = candidate.SelectSingleNode("delivery_line_1").nodeTypedValue
**If Len(candidate.SelectSingleNode("delivery_line_2").nodeTypedValue) > 1 Then
Cells(RowIndex, DPVColumn + 3).Value = candidate.SelectSingleNode("delivery_line_2").nodeTypedValue
End If**
Thanks.