返回列表 上一主題 發帖

請問如何截取指定參數網路內容之指定欄位資料?

回復 2# GBKEE

感謝 GBKEE 版大

試過後已可自動抓取資料,謝謝您!
另外,若要在『代號』參數改變後,自動變更資料,還要加那些程式,請幫忙!
再一次謝謝您!
peter460191

TOP

回復 1# peter460191
  1. Sub Ex()
  2.     Dim E As Range, Ar()
  3.     With Sheets("Sheet1")
  4.         For Each E In .Range(.[A6], .[A6].End(xlDown))   '股票代號區域
  5.             With Sheets("Sheet2").[A1].QueryTable        'Sheet2").[A1] 請設有外部查詢
  6.                 .Connection = "URL;http://justdata.yuanta.com.tw/z/zc/zcc/zcc_" & E & ".asp.htm"
  7.                 .WebSelectionType = xlSpecifiedTables
  8.                 .WebFormatting = xlWebFormattingNone
  9.                 .WebTables = "4"
  10.                 .WebPreFormattedTextToColumns = True
  11.                 .WebConsecutiveDelimitersAsOne = True
  12.                 .WebSingleBlockTextImport = False
  13.                 .WebDisableDateRecognition = False
  14.                 .WebDisableRedirections = False
  15.                 .Refresh BackgroundQuery:=False
  16.                 With .ResultRange
  17.                     Ar = .Range(.Cells(2, 6), .Cells(6, 6)).Value   '年度股利合計範圍
  18.                 End With
  19.             End With
  20.             E.Offset(, 2).Resize(1, 5) = Application.Transpose(Ar)  '年度股利合計 複製於 股票代號區域向右2欄(1列,5欄)
  21.         Next
  22.     End With
  23. End Sub
複製代碼

TOP

        靜思自在 : 話多不如話少,話少不如話好。
返回列表 上一主題