+ Reply to Thread
Results 1 to 2 of 2

Download data from Web to Excel using VBA Macro

Hybrid View

  1. #1
    Registered User
    Join Date
    05-23-2011
    Location
    new zealand
    MS-Off Ver
    Excel 2007
    Posts
    5

    Post Download data from Web to Excel using VBA Macro

    . I had a similar query and everything works the way u explain above, however i am trying to retrieve Income statement, balance sheet and cash flow data. Now my problem is : The data that it retrieves is Quarterly data and not annual data, although i have written a macro for Annual data . Below is the code :
    How do i solve this problem...plz help

    At the same time if i replace the stockSymbol variable with a ticker like WMT (Walmart) then it works fine...
    Public Sub GetHistoricalStockPrices1(ByVal StockSymbol As String)
    With ActiveSheet.QueryTables.Add(Connection:= _
    "URL;http://finance.yahoo.com/q/is?s=" & StockSymbol & "+Income+Statement&annual", Destination _
    :=Range("$c$3"))
    .Name = "is?s=A+Income+Statement&annual"
    .FieldNames = True
    .RowNumbers = False
    .FillAdjacentFormulas = False
    .PreserveFormatting = True
    .RefreshOnFileOpen = False
    .BackgroundQuery = True
    .RefreshStyle = xlInsertDeleteCells
    .SavePassword = False
    .SaveData = True
    .AdjustColumnWidth = True
    .RefreshPeriod = 0
    .WebSelectionType = xlSpecifiedTables
    .WebFormatting = xlWebFormattingNone
    .WebTables = "10"
    .WebPreFormattedTextToColumns = True
    .WebConsecutiveDelimitersAsOne = True
    .WebSingleBlockTextImport = False
    .WebDisableDateRecognition = False
    .WebDisableRedirections = False
    .Refresh BackgroundQuery:=False
    End With
    With ActiveSheet.QueryTables.Add(Connection:= _
    "URL;http://finance.yahoo.com/q/bs?s=" & StockSymbol & "+Balance+Sheet&annual", Destination:= _
    Range("$I$3"))
    .Name = "bs?s=B+Balance+Sheet&annual"
    .FieldNames = True
    .RowNumbers = False
    .FillAdjacentFormulas = False
    .PreserveFormatting = True
    .RefreshOnFileOpen = False
    .BackgroundQuery = True
    .RefreshStyle = xlInsertDeleteCells
    .SavePassword = False
    .SaveData = True
    .AdjustColumnWidth = True
    .RefreshPeriod = 0
    .WebSelectionType = xlSpecifiedTables
    .WebFormatting = xlWebFormattingNone
    .WebTables = "10"
    .WebPreFormattedTextToColumns = True
    .WebConsecutiveDelimitersAsOne = True
    .WebSingleBlockTextImport = False
    .WebDisableDateRecognition = False
    .WebDisableRedirections = False
    .Refresh BackgroundQuery:=False
    End With
    
    With ActiveSheet.QueryTables.Add(Connection:= _
    "URL;http://finance.yahoo.com/q/cf?s=" & StockSymbol & "+Cash+Flow&annual", Destination:= _
    Range("$O$3"))
    .Name = "cf?s=C+Cash+Flow&annual"
    .FieldNames = True
    .RowNumbers = False
    .FillAdjacentFormulas = False
    .PreserveFormatting = True
    .RefreshOnFileOpen = False
    .BackgroundQuery = True
    .RefreshStyle = xlInsertDeleteCells
    .SavePassword = False
    .SaveData = True
    .AdjustColumnWidth = True
    .RefreshPeriod = 0
    .WebSelectionType = xlSpecifiedTables
    .WebFormatting = xlWebFormattingNone
    .WebTables = "10"
    .WebPreFormattedTextToColumns = True
    .WebConsecutiveDelimitersAsOne = True
    .WebSingleBlockTextImport = False
    .WebDisableDateRecognition = False
    .WebDisableRedirections = False
    .Refresh BackgroundQuery:=False
    End With
    
    End Sub
    Sub RunFromButtonPress1()
    GetHistoricalStockPrices1 (ActiveSheet.Range("a1"))
    End Sub
    Last edited by Leith Ross; 05-23-2011 at 09:08 PM. Reason: Added Code Tags

  2. #2
    Registered User
    Join Date
    05-23-2011
    Location
    new zealand
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Download data from Web to Excel using VBA Macro

    Any possible Help on this ....plz, i am stuck...do let me knw if u hv any clue..
    Thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1