Mac Excel 2011 - Excel Web查询 - 循环和选择

时间:2014-08-26 14:19:43

标签: excel macos vba excel-2011

我使用Excel 2011执行以下查询:

WEB
1
http://careers.accel.com/careers_home.php?p=1

Selection=EntirePage
Formatting=All
PreFormattedTextToColumns=True
ConsecutiveDelimitersAsOne=True
SingleBlockTextImport=False

我想知道是否有办法遍历页面的值,即URL中的“p = 1”自动增量为“p = 2”。此外,此查询返回表格顶部的页码,我想知道是否有办法修改我的选择,因此只显示主表。

Excel Rendering Screenshot

1 个答案:

答案 0 :(得分:0)

使用visual basic解决。无法弄清楚删除页码:

' Macro2 Macro
'
For x = 1 To 5
Worksheets("names").Select
Worksheets("names").Activate
mystr = "URL;http://careers.accel.com/careers_home.php?p=1"
mystr = Cells(x, 1)
Worksheets("pages").Activate
'Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name = x
'


 With ActiveSheet.QueryTables.Add(Connection:=mystr, Destination:=Range("$A" & Cells.SpecialCells(xlCellTypeLastCell).Row + 1))
        .PostText = "accel"
        .Name = False
        .FieldNames = False
        .RefreshStyle = xlInsertDeleteCells
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .HasAutoFormat = True
        .RefreshOnFileOpen = 1
        .BackgroundQuery = False
        .TablesOnlyFromHTML = True
        .SaveData = True
        .Refresh BackgroundQuery:=False
        .UseListObject = False


    End With
    Next x
End Sub