hariimmadi
New Member
- Joined
- Dec 13, 2009
- Messages
- 6
Hi,
could someone help me why following code not working. greatly appreciate any help.
this code is getting results for only 3 cells no matter if i loop through 5 or 10 cell values. what could be wrong?
could someone help me why following code not working. greatly appreciate any help.
this code is getting results for only 3 cells no matter if i loop through 5 or 10 cell values. what could be wrong?
Code:
Sub WebQueryQuotes()
Set dest = Range("A8")
For Each cell In [A1:A7]
cell.Select
Item = cell.Value
ConnectString = "URL;http://finance.yahoo.com/q/ks?s=" & cell.Value
Set QT = ActiveSheet.QueryTables.Add(Connection:=ConnectString, Destination:=dest)
With QT
.Name = cell.Value
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = False
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "45"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
'QT.Refresh BackgroundQuery:=True
For Each QT In ActiveSheet.QueryTables
QT.Delete
Next QT
Set dest = dest.Offset(11, 0)
Next cell
End Sub