Excel VBA Webquey 创建新列
Excel VBA Webquey creates new column
例如,下面的查询将创建一个新列 A,并且来自 A 列的数据现在将在列 [=17] 中=]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
Web 查询的目标是否可能保持固定让我们说 A1
是的。在 With 子句中添加 .RefreshStyle = xlOverwriteCells
。这将强制外部数据到 A1 而不是添加新列。
例如,下面的查询将创建一个新列 A,并且来自 A 列的数据现在将在列 [=17] 中=]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
Web 查询的目标是否可能保持固定让我们说 A1
是的。在 With 子句中添加 .RefreshStyle = xlOverwriteCells
。这将强制外部数据到 A1 而不是添加新列。