返回列表 上一主題 發帖

直接抓除息表到工作表中不正常

直接抓除息表到工作表中不正常

股票名稱不正常
Sub 寶來除息表()
Application.ScreenUpdating = False   '除權除息表
Application.EnableEvents = False
Application.DisplayStatusBar = False
ActiveSheet.DisplayPageBreaks = False
    Dim i As Integer, S As Integer, k As Integer, j As Integer
    Dim Element
      With CreateObject("InternetExplorer.Application")
       ' .Visible = True           '可顯示網頁
       .Navigate "http://jdata.yuanta.com.tw/z/ze/zeb/zeb.djhtm"
        Do While .Busy Or .readyState <> 4: DoEvents: Loop
        Set Element = .Document.getElementsByTagName("table")
        On Error Resume Next
        Sheets("sheet1").Range("a:e").ClearContents
        With Sheets("sheet1")
                 For S = 2 To 2                    '已找出網頁的table內容在 0-3 中
                For i = 1 To Element(S).Rows.Length - 1
                    k = k + 1
                   For j = 0 To 4   '資料的欄位共6位
                        .Cells(k, j + 1) = Element(S).Rows(i).Cells(j).innerText
                    Next
                Next
            Next
        End With
       .Quit
    End With
    Set Element = Nothing
   
Application.DisplayStatusBar = True
End Sub
Book2.rar (20.52 KB)

Sub Click_1()
Dim ie
Sheets(1).Select
    Const url As String = "http://jdata.yuanta.com.tw/z/z ...
f3202 發表於 2017-6-22 13:09

謝謝,我只要前5欄 A-E 要改那些地方呢?

TOP

        靜思自在 : 【行善要及時】行善要及時,功德要持續。如燒開水一般,未燒開之前千萬不要停熄火候,否則重來就太費事了。
返回列表 上一主題