[問題] 讀取多個檔案,並import至同一表單
軟體:Excel 2013
版本:2013
大家好,
想請教前輩高手關於VBA編寫的問題
現在在 資料夾中,有3個擷取網路頁面的htm的檔案
1.htm 2.htm 3.htm
在htm網頁裡,當中的第8個表格資料是我要的
我希望將他們讀取進同一個表單,並且如下面這樣
|------------------------------------------------
|1.htm 's table | |
|---------------|-------------------------------|
|2.htm 's table |←接著 1.url's table 下面一行 |
|---------------|-------------------------------|
|3.htm 's table |←接著 2.url's table 下面一行 |
|-----------------------------------------------|
但是我現在得到的卻是...
--------------------------------------------------
|3.htm 's table | 2.htm 's table | 1.htm 's table|
|---------------|----------------|---------------|
| 3的資料 | 2的資料 | 1的資料 |
--------------------------------------------------
請問...我該怎麼修改呢!!!
謝謝!!
程式碼如下:
---
Sub LoadPipeDelimitedFiles()
Dim idx As Integer
Dim fpath As String
Dim fname As String
idx = 0
fpath = "C:\Users\xxxx\Desktop\aaaaa\"
fname = Dir(fpath & "*.htm")
While (Len(fname) > 0)
idx = idx + 1
Sheets("Sheet1").Select
With ActiveSheet.QueryTables.Add(Connection:="URL;" _
& fpath & fname, Destination:=Range("A1"))
.Name = "a" & idx
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "8"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
fname = Dir
End With
Wend
End Sub
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.112.4.235
※ 文章網址: http://www.ptt.cc/bbs/Office/M.1401286255.A.46D.html
→
05/28 22:47, , 1F
05/28 22:47, 1F
→
05/28 22:49, , 2F
05/28 22:49, 2F
Office 近期熱門文章
PTT數位生活區 即時熱門文章