title: Extract Data from a Multiple Web Pages into Excel - using VBA - Excel freezes
body: <p>I am trying to extract the data from the following webpage into excel. The data from the below link spans to 7 pages (appr 3500 rows). I need this data into my excel work workbook.</p>
  
  <p>www.moneycontrol.com/stocks/hist_stock_result.php?ex=N&amp;sc_id=RI&amp;pno=1&amp;hdn=daily&amp;fdt=2000-01-01&amp;todt=2013-11-01</p>
  
  <p>I have used the following macro to download the same....Unfortunately, the macro sreezes the excel application due to unknown reason. Please someone help.....</p>
  
  <pre><code>Private Const URL_TEMPLATE As String = "URL;http://www.moneycontrol.com/stocks/hist_stock_result.php?sc_id=RI&amp;pno={0}&amp;hdn=daily&amp;fdt=2000-01-01&amp;todt=2013-11-01"
  Private Const NUMBER_OF_PAGES As Byte = 7
  
  Sub test()
      Dim page As Byte
      Dim queryTableObject As QueryTable
      Dim url As String
  
      For page = 1 To NUMBER_OF_PAGES
          url = VBA.Strings.Replace(URL_TEMPLATE, "{0}", page)
          Set queryTableObject = ActiveSheet.QueryTables.Add(Connection:=url, Destination:=ThisWorkbook.Worksheets.Add.[a1])
          queryTableObject.WebSelectionType = xlSpecifiedTables
          queryTableObject.WebTables = "3"
          queryTableObject.Refresh
      Next page
  
  End Sub
  </code></pre>