1

使用 VBA,我需要从网页http://emops.tse.com.tw/t21/sii/t21sc03_2011_9_e.htm中提取数据

我可以使用以下代码获取所有数据:

With ActiveSheet.QueryTables.Add(Connection:="URL;http://emops.tse.com.tw/t21/sii/t21sc03_2012_2_e.htm", Destination:=Range("$A$1"))
        .Name = "67083361_zpid"
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .WebSelectionType = xlEntirePage
        .WebFormatting = xlWebFormattingNone
        .WebPreFormattedTextToColumns = True
        .WebConsecutiveDelimitersAsOne = True
        .WebSingleBlockTextImport = False
        .WebDisableDateRecognition = False
        .WebDisableRedirections = False
        .Refresh BackgroundQuery:=False
End With

但问题是我不想要整个页面的数据。我想要行业名称为 Electron 的表中的数据(在这种情况下是最后一个表)

请问有什么技巧吗?

4

1 回答 1

3

改变:

.WebSelectionType = xlEntirePage to .WebSelectionType = xlSpecifiedTables

添加:

.WebTables = "2" below .WebFormatting = xlWebFormattingNone

'您将不得不对“2”使用反复试验来找到您想要抓取的确切表格

于 2014-04-30T15:29:21.467 回答