|
-
Jan 24th, 2011, 02:09 AM
#1
Thread Starter
New Member
[Excel 2007] Pulling Web Data
Hey everyone,
Have a question regarding my code.... I have symbols listed down a column in which I wish to pull income statements off from Yahoo Finance. It would be great to be able to place them sequentially down column B. My problem right now is trying to get my script to work. When attempting to execute it, with only three symbols listed down column A, I get the error: "Expected Array." Can anyone assist in solving this error, and possibly helping with sequentially inserting income statements below previously inserted ones?
Thank you in advance,
AC
Code:
Sub RevenueMacro()
' Revenue Macro
' Lists the income statement from Yahoo Finance for a given stock symbol
Dim ArSymbol As String
ArSymbol = ActiveSheet.Range("A:A")
If IsEmpty(ActiveCell) = False Then
For i = LBound(ArSymbol) To UBound(ArSymbol)
ArSymbol = ActiveCell.Value
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://finance.yahoo.com/q/is?s=" & ArSymbol & "+Income+Statement&annual", _
Destination:=Range("$A$2"))
.Name = "is?s=" & ArSymbol & "+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
Next
End If
If IsEmpty(ActiveCell) = True Then
Exit_RevenueMacro:
Exit Sub
End If
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|