Jumat, 02 Januari 2015

[ExcelVBA] QueryTables



Happy New Year to all!

I have a query I am doing to the nasdaq to get Income Statements. I started with Annual Statements and the query works wells.

thisurl = "http://www.nasdaq.com/symbol/" & Symbol & "/financials?query=income-statement"

I bring in the full page and then clean it up, no problem. But then I decided I would give the user the choice to get quarterly data instead.

YrorQtr = UCase(InputBox("Yearly or quarterly?", "Yr or Qr", "Yr Qr"))

Then I use a simple if statement to choose the URL

If YrorQtr = "YR" Then
    thisurl = "http://www.nasdaq.com/symbol/" & Symbol & "/financials?query=income-statement"
  ElseIf YrorQtr = "QR" Then  (THIS IS WHAT FAILS)
    thisurl = "http://www.nasdaq.com/symbol/" & Symbol & "/financials?query=income-statement&data=quarterly"
  End If
  Set QT = ActiveSheet.QueryTables.Add(Connection:="URL;" & thisurl, _
  With QT
    .WebSelectionType = xlEntirePage
    .Refresh BackgroundQuery:=False
  End With

It always gives me annual statements. Any ideas how I can change this.

Thanks for your time and efforts.



Posted by: who1012000@yahoo.com
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (1)
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

Visit our ExcelVBA group home page for more info and support files:

More free tutorials and resources available at:




Tidak ada komentar:

Posting Komentar