title: Importing table to Excel that was generated by a script from a webpage
body: <p>I've been trying to import the following table into Excel</p>
  
  <p>www.bursamalaysia.com/market/securities/equities/indices/</p>
  
  <p>I've tried PowerQuery, Data Tab "From Web" etc. From my research, I've come to believe that the reason that Excel cannot "see" the data is because it was dynamically generated with Javascript.</p>
  
  <p>I would appreciate any help trying to get the table into excel via PowerQuery or even a VBA script.</p>
  
  <p>I saw something similar <a href="https://stackoverflow.com/questions/21039677/import-data-in-excel-from-a-table-created-by-a-script-in-a-webpage">at this</a> and modified it as follows but I am getting an empty table.</p>
  
  <pre><code>Sub Bursa_Indices()
  
  Dim xmlHttp As Object
  Dim TR_col As Object, TR As Object
  Dim TD_col As Object, TD As Object
  Dim row As Long, col As Long
  
  Set xmlHttp = CreateObject("MSXML2.XMLHTTP.6.0")
  xmlHttp.Open "GET", "http://www.bursamalaysia.com/market/securities/equities/indices/", False
  xmlHttp.setRequestHeader "Content-Type", "text/xml"
  xmlHttp.send
  
  Dim html As Object
  Set html = CreateObject("htmlfile")
  html.body.innerHTML = xmlHttp.ResponseText
  
  Dim tbl As Object
  Set tbl = html.getElementById("bm_indices_prices_table")
  
  row = 1
  col = 1
  
  Set TR_col = html.getelementsbytagname("TR")
  For Each TR In TR_col
      Set TD_col = TR.getelementsbytagname("TD")
      For Each TD In TD_col
          Cells(row, col) = TD.innerText
          col = col + 1
      Next
      col = 1
      row = row + 1
  Next
  </code></pre>
  
  <p>End Sub</p>
  
  <p>Thanks in advance.</p>