On May 2, 2017, at 2:18 AM, 方家晟 wrote:
看到您已用CSV解決...目前在下也無能為力。希望有更好的解決方案,助您好運。
這個問題也有許多國外的EXCEL在抱怨:Some parts of this page is not supported on your current browser version.
1. 不確定CSV方法是否能在不同電腦環境通用:
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;
http://chart.finance.yahoo.com/table.csv?s=KO&a=4&b=2&c=2012&d=4&e=2&f=2017&g=v&ignore=.csv", Destination:=Range("A1"))
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.Refresh BackgroundQuery:=False
End With
2. 如果照原本網頁匯入CSV,得再自行處理逗號分隔:
Dim dl0 As Long, dlr As Integer
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;
http://chart.finance.yahoo.com/table.csv?s=KO&a=4&b=2&c=2012&d=4&e=2&f=2017&g=v&ignore=.csv", Destination:=Range( _
"$A$1"))
.Refresh BackgroundQuery:=False
End With
dl0 = 1
dlr = UBound(Split(Range("$A$1"), ","))
Do While Cells(dl0, 1) <> ""
Range(Cells(dl0, 1), Cells(dl0, 1 + dlr)) = Split(Cells(dl0, 1), ",")
dl0 = dl0 + 1
Loop
--
方家晟 Ben