返回列表 上一主題 發帖

[發問] 資料抓取另存在不同sheet, 出現錯誤1004

回復 1# b7502040
  1. Private Sub CommandButton1_Click()
  2.    With Sheets(2)
  3.     .Columns("A:AC").ClearContents
  4.     With .QueryTables.Add(Connection:= _
  5.         "URL;http://mops.twse.com.tw/mops/web/ajax_t51sb01?step=1&firstin=1&TYPEK=sii" _
  6.         , Destination:=.Range("$A$1"))
  7.         .Name = "ajax_t51sb01?step=1&firstin=1&TYPEK=sii"
  8.         .FieldNames = True
  9.         .RowNumbers = False
  10.         .FillAdjacentFormulas = False
  11.         .PreserveFormatting = True
  12.         .RefreshOnFileOpen = False
  13.         .BackgroundQuery = True
  14.         .RefreshStyle = xlInsertDeleteCells
  15.         .SavePassword = False
  16.         .SaveData = True
  17.         .AdjustColumnWidth = True
  18.         .RefreshPeriod = 0
  19.         .WebSelectionType = xlEntirePage
  20.         .WebFormatting = xlWebFormattingNone
  21.         .WebPreFormattedTextToColumns = True
  22.         .WebConsecutiveDelimitersAsOne = True
  23.         .WebSingleBlockTextImport = False
  24.         .WebDisableDateRecognition = False
  25.         .WebDisableRedirections = False
  26.         .Refresh BackgroundQuery:=False
  27.     End With
  28.     .Columns("C:AB").Delete Shift:=xlToLeft
  29.     .Rows("1:1").Delete Shift:=xlUp
  30.    End With
  31. End Sub
複製代碼
學海無涯_不恥下問

TOP

        靜思自在 : 忘功不忘過,忘怨不忘恩。
返回列表 上一主題