title: How to get the values from XML tags to Excel sheet?
body: <p>I am inexperienced in vba coding, got a requirement to pull the values from the xml file to excel sheet. Tried to code with the help of google, but not succeeded. Below is my xml file</p>
  
  <pre><code>&lt;CRD&gt;
  ..
  &lt;PLAN&gt;Plan01&lt;/PLAN&gt;
  ..
  &lt;/CRD&gt;
  </code></pre>
  
  <p>Below are My tested codes :</p>
  
  <p>Code 1</p>
  
  <pre><code>Private Sub RunTest_Click()
  
  Dim envFrmwrkPath As String
  Dim objfso, app, Eval As Object
  
  envFrmwrkPath = ActiveSheet.Range("E6").Value
  
  Set EnvVarXML = CreateObject("Microsoft.XMLDOM")
  
  EnvVarXML.Load (envFrmwrkPath &amp; "CRD-0071709[1].xml")
  
  For Each UIElement In EnvVarXML.SelectNodes("//CRD")
  Set Field = Eval(objUIElement.SelectSingleNode("PLAN").Text)
  Sheet1.Cells(2, 2).Value = Field
  Next
  
  End Sub
  </code></pre>
  
  <p>Code 2</p>
  
  <pre><code>Sub ImportXMLtoList()
  
  Dim xml_doc As New MSXML2.DOMDocument60
  Dim onode As MSXML2.IXMLDOMElement
  Dim chnode As MSXML2.IXMLDOMElement
  Dim brtn As Boolean
  
  brtn = xml_doc.Load("D:\Satheesh 244688\CI Team\Med D Formulary Testing\May 8th\CRD-0071709[1].xml")
  
  'Set onode = xml_doc.SelectSingleNode("/CRD")
  
  For Each onode In xml_doc.SelectSingleNode("//CRD")
  
  nm = onode.nodeName
  If nm = "RxPlanID" Then
  Sheet1.Cells(2, 2) = chnode.Text
  End If
  
  Next
  
  End Sub
  </code></pre>