返回列表 上一主題 發帖

[發問] 無法匯入PCHOME 股市資料

回復 9# tajen
提供參考: (不知是否吻合你的需求?)
  1. Sub 最佳五檔()
  2.     Dim Sh As Worksheet
  3.    
  4.     Set Sh = Sheets("工作表3")                   '  可指定工作表
  5.    
  6.     With Sh
  7.         .Cells.Clear
  8.         .Select
  9.         
  10.         With .QueryTables.Add(Connection:= _
  11.             "URL;http://traderoom.cnyes.com/tse/quote2FB.aspx?code=6121", Destination:= _
  12.                                                                           .Range("F1"))
  13.             .WebFormatting = xlWebFormattingNone
  14.             .WebTables = "7"
  15.             .Refresh BackgroundQuery:=False
  16.         End With
  17.         
  18.         With .QueryTables.Add(Connection:= _
  19.             "URL;http://traderoom.cnyes.com/tse/quote2FB.aspx?code=6121", Destination:= _
  20.                                                                           .Range("A1"))
  21.             .WebFormatting = xlWebFormattingNone
  22.             .WebTables = "8,10,11"    '  網頁的表格,更改 WebTables 就行了
  23.             '  .WebTables = "7,8,10,11"
  24.             '  .WebTables = "6,8,10,11"
  25.             .Refresh BackgroundQuery:=False
  26.         End With
  27.         
  28.         With .QueryTables.Add(Connection:= _
  29.             "URL;http://traderoom.cnyes.com/tse/quote2FB.aspx?code=6121", Destination:= _
  30.                                                                           .Range("I1"))
  31.             .WebFormatting = xlWebFormattingNone
  32.             .WebTables = "6"
  33.             .Refresh BackgroundQuery:=False
  34.         End With
  35.         
  36.         .Range("A:N").EntireColumn.AutoFit
  37.     End With
  38. End Sub
複製代碼

TOP

        靜思自在 : 能善用時間的人,必能掌握自己努力的方向。
返回列表 上一主題