【问题标题】:Mac Excel 2011 - Excel Web Query - Loops and SelectionsMac Excel 2011 - Excel Web 查询 - 循环和选择
【发布时间】:2014-08-26 14:19:43
【问题描述】:
我正在使用 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
macos
vba
excel-2011
【解决方案1】:
使用 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