I'm trying to create a macro that will download corporate financial data from a website for the purposes of stock research.
I believe I have it working for the most part, but one table specifically is giving me trouble. The balance sheet is not downloading the complete table. I've tried manipulating the code to include the whole webpage, various tables, or the specific table (2). It seems to stop at the same point no matter how I go about it.
The table in question is a balance sheet, and the last row should be "Diluted Shares Outstanding". When I use Excel's webquery (either manually or various ways through a macro), the last row is "Other Long-Term Assets". That is only the first 1/4th of the table.
For the example below, the URL that I am trying to pull information from is http://www.smartmoney.com/eqsnaps/i...=YB&isFinprint=1&framework.view=smi_plainView.
Please look over the code below and see if I may have made a mistake. I also wonder if the HTML on the site may not be formated correctly. I took a look at the source of the webpage, but couldn't spot anything.
I should also note that this is not an issue with the Cash Flow and Income Statement data from the same site.
Thank you for any assistance that is provided.
I believe I have it working for the most part, but one table specifically is giving me trouble. The balance sheet is not downloading the complete table. I've tried manipulating the code to include the whole webpage, various tables, or the specific table (2). It seems to stop at the same point no matter how I go about it.
The table in question is a balance sheet, and the last row should be "Diluted Shares Outstanding". When I use Excel's webquery (either manually or various ways through a macro), the last row is "Other Long-Term Assets". That is only the first 1/4th of the table.
For the example below, the URL that I am trying to pull information from is http://www.smartmoney.com/eqsnaps/i...=YB&isFinprint=1&framework.view=smi_plainView.
Please look over the code below and see if I may have made a mistake. I also wonder if the HTML on the site may not be formated correctly. I took a look at the source of the webpage, but couldn't spot anything.
I should also note that this is not an issue with the Cash Flow and Income Statement data from the same site.
Thank you for any assistance that is provided.
Code:
Sub BalanceSheet()
Dim QT As QueryTable
'Balance Sheet 1
MyName = "Balance Sheet 1"
ConnectString = "URL;http://www.smartmoney.com/eqsnaps/index.cfm?called=1&story=financials&timewindow=1&symbol=F&opt=YB&isFinprint=1&framework.view=smi_plainView"
Sheet2.Activate
Set QT = ActiveSheet.QueryTables.Add(Connection:=ConnectString, Destination:=Range("A1"))
With QT
.Name = MyName
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = False
.RefreshOnFileOpen = False
.BackgroundQuery = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingRTF
.WebTables = "2"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
End With
QT.Refresh BackgroundQuery:=True
End Sub