【问题标题】:Excel VBA Webquey creates new columnExcel VBA Webquey 创建新列
【发布时间】:2016-02-10 19:26:38
【问题描述】:

例如,以下查询将创建一个新列 A 并且来自 A 列的数据现在将位于列 B

With ActiveSheet.QueryTables.Add(Connection:="URL;" & u, _
Destination:=Cells(14, 8))
    .BackgroundQuery = True
    .TablesOnlyFromHTML = True
    .Refresh BackgroundQuery:=False
    .SaveData = True
    .FieldNames = True
    .RowNumbers = False
    .FillAdjacentFormulas = False
    .PreserveFormatting = False
    .RefreshOnFileOpen = False
    .BackgroundQuery = True
    .RefreshStyle = xlOverwriteCells
    .SavePassword = False
    .SaveData = True
    .RefreshPeriod = 0
    .WebSelectionType = xlEntirePage
    .WebFormatting = xlWebFormattingNone
    .WebPreFormattedTextToColumns = True
    .WebConsecutiveDelimitersAsOne = True
    .WebSingleBlockTextImport = False
    .WebDisableDateRecognition = False
    .WebDisableRedirections = False
    .Refresh BackgroundQuery:=False
    .AdjustColumnWidth = False
End With

网络查询的目的地是否有可能保持固定让我们说 A1

【问题讨论】:

    标签: excel vba excel-web-query


    【解决方案1】:

    是的。在 With 子句中添加 .RefreshStyle = xlOverwriteCells。这将强制外部数据到 A1,而不是添加新列。

    【讨论】:

    • 我已经更新了您在上面看到的代码,但是仍然无法正常工作 excel 总是插入一个新列
    • 我建议您只在之前的代码中添加这一行。还将目标属性更改为范围($A$1)。它在 excel 2010 上对我有用。没有添加任何列,新数据会覆盖单元格 a1 上的任何内容
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-15
    • 2018-03-09
    • 1970-01-01
    相关资源
    最近更新 更多