- 帖子
- 219
- 主題
- 24
- 精華
- 0
- 積分
- 243
- 點名
- 0
- 作業系統
- Windows10
- 軟體版本
- Office2016
- 閱讀權限
- 20
- 性別
- 女
- 註冊時間
- 2012-4-18
- 最後登錄
- 2022-2-7
 
|
回復 10# lalalada
參考!參考!~~有誤請糾正我!
我的理解是
.RefreshStyle = xlOverwriteCells '= xlOverwriteCells '覆蓋原欄位 = xlInsertDeleteCells '插入新資料,原資料右移
所以抓完全頁面之後的應用
Option Explicit
Sub Ex()
Dim QueryTable_Name As String
With ActiveSheet
With .QueryTables.Add(Connection:="URL;http://******", Destination:=Range("A1"))
QueryTable_Name = .Name
.RefreshStyle = xlOverwriteCells '= xlOverwriteCells '覆蓋原欄位 = xlInsertDeleteCells '插入新資料,原資料右移
.Refresh BackgroundQuery:=False
End With
.Names(QueryTable_Name).Delete '刪除:查詢在工作表所定義的範圍名稱
End With
'這裡另外剪貼出去,讓檔案各自獨立
Columns("資料範圍").Select
Selection.Cut '剪下資料的範圍
Workbooks.Add '新增資料表
Range("A1").Paste
Application.CutCopyMode = False
ActiveWorkbook.SaveAs
End Sub |
|