返回列表 上一主題 發帖

vba匯入券商進出表

你可以試試一句一句試試了解一下意思
  1. Sub GetTransInfo()
  2. Worksheets("sheet2").Activate
  3. Call 券商進出("2885", "sheet2", "A1")
  4. 'Call 券商進出("2409", "sheet2", "A60")
  5. End Sub
  6. Sub 券商進出(stock As String, tsheet As String, tcell As String)
  7.     '"all&stockid",
  8.     Call 券商進出2("8,10,11", stock, tsheet, tcell)
  9. End Sub

  10. '(all&stockid,
  11. Sub 券商進出2(tbl As String, stock As String, tsheet As String, tcell As String)
  12.      With Worksheets(tsheet).QueryTables.Add(Connection:="URL;http://yamstock.megatime.com.tw/asp/stockinfo/ps_top.asp?m=all&stockid=" & _
  13.         stock & "&name1=D2&index1=6", _
  14.         Destination:=Worksheets(tsheet).Range(tcell))
  15.         .Name = all & "_" & stock
  16.          .FieldNames = True
  17.         .FieldNames = True
  18.         .RowNumbers = False
  19.         .FillAdjacentFormulas = False
  20.         .PreserveFormatting = True
  21.         .RefreshOnFileOpen = False
  22.         .BackgroundQuery = False
  23.         .RefreshStyle = xlOverwriteCells
  24.         .SavePassword = False
  25.         .SaveData = True
  26.         .AdjustColumnWidth = True
  27.         .RefreshPeriod = 0
  28.         .WebSelectionType = xlSpecifiedTables
  29.         .WebFormatting = xlWebFormattingNone
  30.         .WebTables = tbl
  31.         .WebPreFormattedTextToColumns = True
  32.         .WebConsecutiveDelimitersAsOne = True
  33.         .WebSingleBlockTextImport = False
  34.         .WebDisableDateRecognition = False
  35.         .WebDisableRedirections = False
  36.         .Refresh BackgroundQuery:=False
  37.     End With

  38.     End Sub
複製代碼
懂得發問,答案就會在其中

今日の一秒は  明日にない
http://kimbalko-chi.blogspot.com
http://kimbalko.blogspot.com

TOP

        靜思自在 : 虛空有盡.我願無窮,發願容易行願難。
返回列表 上一主題