我能';t使用vba重写excel中的表格

我能';t使用vba重写excel中的表格,excel,vba,Excel,Vba,我在excel VBA中有以下代码 'Create query table to hold the rates. With objBK.Worksheets(1) Set objQT = .QueryTables.Add( _ Connection:="URL;https://xxx.output=XLS", _ Destination:=.Range("A1")) End With https://xxx.output=XLS

我在excel VBA中有以下代码

   'Create query table to hold the rates.
   With objBK.Worksheets(1)
      Set objQT = .QueryTables.Add( _
         Connection:="URL;https://xxx.output=XLS", _
         Destination:=.Range("A1"))
   End With
https://xxx.output=XLS
返回在我的工作表的A1单元格中写入的XLS表格

问题是,每次我运行此查询时,它都会在A1中不断添加表,移动上一个表,而不是覆盖它


如何覆盖旧表?

当您实际需要调整现有表时,会不断添加新表。为您的查询表命名(objQT.name=“blah”)。然后,当您需要调整它时,抓住该查询表并对其进行调整

或者,只需在创建新文件之前删除旧文件