Extract Data from a Multiple Web Pages into Excel - using VBA - Excel freezes

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. www.moneycontrol.com/stocks/hist_stock_result.php?ex=N&sc_id=RI&pno=1&hdn=daily&fdt=2000-01-01&todt=2013-11-01 I have used the following macro to download the same....Unfortunately, the macro sreezes the excel application due to unknown reason. Please someone help..... Private Const URL_TEMPLATE As String = "URL;http://www.moneycontrol.com/stocks/hist_stock_result.php?sc_id=RI&pno={0}&hdn=daily&fdt=2000-01-01&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

以上就是Extract Data from a Multiple Web Pages into Excel - using VBA - Excel freezes的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » excel

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准