我能够使用链接“ http://www.advfn.com/stock-market/NASDAQ/NVDA/financials?btn=annual_reports&mode=company_data ”上的网络查询将财务报表导入 excel 。我将导入过程记录到一个宏中,并稍微修补了 vba 代码以使其运行。现在,我想根据单元格 A1 中的股票代码刷新导入的财务报表。但是,我得到一个下标超出范围错误,我似乎无法弄清楚为什么。请查看下面的代码并尽可能提供任何见解。
Sub finstate()
'
' finstate Macro
'
'
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://www.advfn.com/stock-market/NASDAQ/" & Worksheets("Input").Range("A1").Value & "/financials?btn=annual_reports&mode=company_data" _
, Destination:=Range("B2"))
.Name = "financials?btn=annual_reports&mode=company_data"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = False
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingAll
.WebTables = "6"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub
太感谢了!