Sub 下載即時資料()
Dim nRow As Integer
Dim I As Integer
Dim X As Integer
Dim Y As Integer
Dim J As Integer
Dim QryTbl As QueryTable
Dim WebAddress As String
WebAddress = "http://tw.futures.finance.yahoo.com/future/l/opt_TXO_1.html?rr=13022289583560.9952862945437091"
With ThisWorkbook.Worksheets("Sheet1")
.Cells.Clear
Set QryTbl = .QueryTables.Add("URL;" & WebAddress, .Range("A1"))
End With
With QryTbl
.WebTables = "7,8,10"
.WebFormatting = xlWebFormattingNone
.WebSelectionType = xlSpecifiedTables
.RefreshPeriod = 0
.Refresh BackgroundQuery:=False
End With
For I = 7 To Y
J = J + 1
X = Worksheets("Sheet1").Cells(I, 1)
Workbooks("B").Worksheets("Sheet1").Copy _
after:=Workbooks("A").Worksheets(1)
ActiveSheet.Name = X
ActiveSheet.Range("H1") = "履約價"
ActiveSheet.Range("H2") = X
ActiveSheet.Range("I1") = "即時成交價"
ActiveSheet.Range("J1") = "歷史成交價"
Select Case Len(ActiveSheet.Range("H2"))
Case Is = 4
ActiveSheet.Range("I2").Formula = "=CATDDE|'FUTOPT<FO>TXO0" & X & "E1'!CurPrice"
Case Is = 5
ActiveSheet.Range("I2").Formula = "=CATDDE|'FUTOPT<FO>TXO" & X & "E1'!CurPrice"
End Select
Next I
End Sub
Public J As Integer
Sub 下載即時資料()
Dim nRow As Integer
Dim I As Integer
Dim X As Integer
Dim Y As Integer
' Dim J As Integer
Dim QryTbl As QueryTable
Dim WebAddress As String作者: ko310kmo 時間: 2011-4-26 16:41