title: Scraping dynamic web page with VBA based on XMLHTTP object
body: <p>I have problem with scraping table data from this page [<a href="http://www.eex.com/en/market-data/power/derivatives-market/phelix-futures]" rel="nofollow">http://www.eex.com/en/market-data/power/derivatives-market/phelix-futures]</a>. I use this code, but do not scrape any data:</p>
  
  <pre><code>Public Sub ScrapTableData()
      Dim sURL As String
      Dim XMLHttpRequest As XMLHTTP
      Dim HTMLDoc As New HTMLDocument
      Dim elc As HTMLHtmlElement
      Dim i As Integer
  
      sURL = "http://www.eex.com/en/market-data/power/derivatives-market/phelix-futures"
  
      Set XMLHttpRequest = New MSXML2.XMLHTTP
      XMLHttpRequest.Open "GET", sURL, False
      XMLHttpRequest.responseXML.async = False
      XMLHttpRequest.send
  
      Do While XMLHttpRequest.Status &lt;&gt; 200
          DoEvents
      Loop
      While XMLHttpRequest.ReadyState &lt;&gt; 4
          DoEvents
      Wend
  
      HTMLDoc.body.innerHTML = XMLHttpRequest.responseText
  
      ' Tables
      Dim tbl    As HTMLTable, row    As HTMLTableRow, cell   As HTMLTableCell
      i = 1
      For Each tbl In HTMLDoc.getElementsByTagName("table")
         For Each row In tbl.Rows
             For Each cell In row.Cells
                 ActiveSheet.Cells(i, 5) = cell.innerText
                 i = i + 1
             Next
         Next
      Next
  End Sub
  </code></pre>
  
  <p>My code does not find HTML <code>table</code> tags.</p>
  
  <p>Also, if I use this part of code, do not list all HTML tags (for example HTML <code>DIV</code> tag) and HTML that describes 6 buttons:</p>
  
  <pre><code>i = 0
  Dim elc As HTMLHtmlElement
  For Each elc In HTMLDoc.all
      Worksheets("Tables").Range("A1").Offset(i, 0) = elc.tagName
      i = i + 1
  Next
  </code></pre>
  
  <p>6 buttons: Year, Quarter, Month,..., Day</p>
  
  <p>I need to simulate click on them to display (scrape) different tables' data.</p>