- 帖子
- 9
- 主題
- 0
- 精華
- 0
- 積分
- 14
- 點名
- 0
- 作業系統
- windows7
- 軟體版本
- 9
- 閱讀權限
- 10
- 性別
- 男
- 註冊時間
- 2012-7-31
- 最後登錄
- 2012-12-3
|
5#
發表於 2012-7-31 23:46
| 只看該作者
以下的程式碼可以更新
你可以多嘗試看看
我只抓取期交所網站的資料,而期交所在交易日收盤後下午三點更新資料- Sub 台指期OI資料一()
- '================================================================================================================================
- Dim MyUrl As String
- '================================================================================================================================
- Application.ScreenUpdating = False '加快處理速度
- Worksheets("Temp").Select '暫存資料的網頁
- Cells.Clear
- MyUrl = "URL;http://www.taifex.com.tw/chinese/3/3_1_1.asp"
- With ActiveSheet.QueryTables.Add(Connection:=MyUrl, Destination:=Range("A1"))
- .FieldNames = True
- .RowNumbers = False
- .FillAdjacentFormulas = False
- .PreserveFormatting = True
- .RefreshOnFileOpen = False
- .BackgroundQuery = True
- .RefreshStyle = xlInsertDeleteCells
- .SavePassword = False
- .SaveData = True
- .AdjustColumnWidth = True
- .RefreshPeriod = 0
- .WebSelectionType = xlEntirePage
- .WebFormatting = xlWebFormattingNone
- .WebPreFormattedTextToColumns = True
- .WebConsecutiveDelimitersAsOne = True
- .WebSingleBlockTextImport = False
- .WebDisableDateRecognition = False
- .WebDisableRedirections = False
- .Refresh BackgroundQuery:=False
- End With
- '--------------------------------------------------------------------------
-
- Bye:
- '--------------------------------------------------------------------------
- Delete_Rows
- '--------------------------------------------------------------------------
- End Sub
- Private Function Delete_Rows()
- '==========================================================================
- Dim Temp_Count As Integer
- Dim Key_Point As String
- Dim Data_Row As Integer
- Dim Delete_Row As Integer
- Dim I As Integer
- '==========================================================================
- Temp_Count = Worksheets("Temp").Range("A65536").End(xlUp).Row
- '--------------------------------------------------------------------------
- StepA:
- '--------------------------------------------------------------------------
- '找出關鍵字元,判斷所需資料的欄位
- '--------------------------------------------------------------------------
- For I = 1 To Temp_Count
- Key_Point = Worksheets("Temp").Range("A" & I).Value
- If Key_Point = "臺股期貨 (TX) 行情表" Then
-
- Data_Row = I
-
- GoTo StepB
-
- End If
-
- Next I
- '--------------------------------------------------------------------------
- StepB:
- '--------------------------------------------------------------------------
- '刪除不必要的資料
- '--------------------------------------------------------------------------
- Delete_Row = Data_Row - 3
- Rows("1:" & Delete_Row).Select
- Selection.Delete Shift:=xlUp
- '--------------------------------------------------------------------------
- End Function
複製代碼 |
|