-
Solved: extract data from website to excel
In I1, put formula =TEXT(J1)
In J1 ,put ^DJI,say. What's wrong with the following code ,plse?
With Worksheets("Sheet1").QueryTables.Add(Connection:= _ "URL;http://ichart.finance.yahoo.com/table.csv?s=" & Cells(1, "I")&a=08&b=13&c=2011&d=06&e=6&f=2013&g=w&ignore=.xlsx"
-
Can you show us the direct link?
-
I think I got it. You had left the Destination range off, and there was a missing quote.
[vba]With Worksheets("Sheet2").QueryTables.Add(Connection:= _
"URL;http://ichart.finance.yahoo.com/table.csv?s=" _
& Sheet2.Cells(1, "I").Value & "&a=08&b=13&c=2011&d=06&e=6&f=2013&g=w&ignore=.csv", _
Destination:=Sheet2.Range("a1"))[/vba]
I tried it without the qualified range (Sheet2.Cells(1, "I").Value vs Cells(1, "I") ), but it would error out.
I couldn't get the xlsx extension to work either,
HTH
-
[VBA]On Error Resume Next
ThisWorkbook.Connections(1).Delete
Err.Clear: On Error Goto 0
With Worksheets("Sheet1").QueryTables.Add(Connection:= _
"URL;http://ichart.finance.yahoo.com/table.csv?s=^STI&a=08&b=13&c=2011&d=06&e=6&f=2013&g=w&ignore=.xlsx _
, Destination:=Range("$A$1"))
.Name = _
"MyData"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = 0
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "4"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.Refresh BackgroundQuery:=False
End With [/VBA]
-
[VBA]With Worksheets("Sheet1").QueryTables.Add(Connection:= _
"URL;http://ichart.finance.yahoo.com/table.csv?s=" & _
Worksheets("Sheet1").Range("J1").Value & "&a=08&b=13&c=2011&d=06&e=6&f=2013&g=w&ignore=.xlsx" _
, Destination:=Worksheets("Sheet1").Range("$A$1"))[/VBA]
-
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