I was able to import financial statements into excel using web query on the link "http://www.advfn.com/stock-market/NASDAQ/NVDA/financials?btn=annual_reports&mode=company_data". I recorded the import process into a macro and patched up the vba code a bit to have it run. Now, I would like to make the imported financial statements refresh based on a stock ticker I have in cell A1. However, I am getting a subscript is out of range error and i can't seem to figure out why. Please view the code below and provide any insights if possible.
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
Thank you so much!