我正在尝试将以下网页中的数据提取到 excel 中。以下链接中的数据跨越 7 页(大约 3500 行)。我需要这些数据到我的 excel 工作簿中。
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
我已经使用以下宏下载了相同的....不幸的是,由于未知原因,宏将 excel 应用程序压缩。请有人帮忙......
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