title: Problem encountered while trying to remove select in query table refresh code
body: <p>I have successfully connected to a text file as per given code by using Excel's Get &amp; Transform (Power Query) experience to connect to Text files.
  Next base text file is <code>Axis1.txt</code> which changes periodically.
  Next I went to refresh the query table  with latest data.
  I referred following references to learn about refreshing querytables</p>
  
  <p><a href="https://stackoverflow.com/questions/39027286/how-to-reference-and-refresh-a-querytable-in-excel-2016-in-vba">How to reference and refresh a QueryTable in Excel 2016 in VBA</a></p>
  
  <p><a href="https://stackoverflow.com/questions/51982136/excel-vba-refresh-data-from-specific-source-without-dialog/51983783#51983783">Excel VBA / Refresh data from specific source without dialog</a></p>
  
  <p><a href="https://docs.microsoft.com/en-us/office/vba/api/excel.querytable.refresh" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/office/vba/api/excel.querytable.refresh</a></p>
  
  <p><strong>Now my Problem</strong> . </p>
  
  <p>Out of all referred methods I could get success in refreshing table with latest data when one of the query table cell is selected and the following command is given.</p>
  
  <pre><code>Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False
  </code></pre>
  
  <p>Other types of code syntax refereed in various posts encounter an error mentioned against each line.</p>
  
  <pre><code>Sub reresh1()
  'Sheet2.ListObject.QueryTable.Refresh BackgroundQuery:=False
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/Wr1Q9.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Wr1Q9.jpg" alt="errorl2"></a></p>
  
  <pre><code>  'Sheets("Sheet2").QueryTables.Refresh BackgroundQuery:=False
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/6eIdi.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6eIdi.jpg" alt="errorl3"></a></p>
  
  <pre><code>  Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False
     'WORKS FINE
  
     End Sub
  </code></pre>
  
  <p>Various other code syntax combinations were also tried but could not get success.</p>
  
  <pre><code>Sub TblImpV1()
  ' Macro1 Macro
      ActiveWorkbook.Queries.Add Name:="axis1", Formula:= _but 
          "let" &amp; Chr(13) &amp; "" &amp; Chr(10) &amp; "    Source = Csv.Document(File.Contents(""C:\mydirb\axis1.txt""),[Delimiter=""    "", Columns=11, Encoding=1252, QuoteStyle=QuoteStyle.None])," &amp; Chr(13) &amp; "" &amp; Chr(10) &amp; "    #""Changed Type"" = Table.TransformColumnTypes(Source,{{""Column1"", Int64.Type}, {""Column2"", type date}, {""Column3"", type text}, {""Column4"", type text}, {""Column5"", type text}, {""Column6"", type number}, {""C" &amp; _
          "olumn7"", type number}, {""Column8"", type text}, {""Column9"", type text}, {""Column10"", type text}, {""Column11"", type text}})" &amp; Chr(13) &amp; "" &amp; Chr(10) &amp; "in" &amp; Chr(13) &amp; "" &amp; Chr(10) &amp; "    #""Changed Type"""
      ActiveWorkbook.Worksheets.Add
      With ActiveSheet.ListObjects.Add(SourceType:=0, Source:= _
          "OLEDB;Provider=Microsoft.Mashup.OleDb.1;Data Source=$Workbook$;Location=axis1;Extended Properties=""""" _
          , Destination:=Range("$A$1")).QueryTable
          .CommandType = xlCmdSql
          .CommandText = Array("SELECT * FROM [axis1]")
          .RowNumbers = False
          .FillAdjacentFormulas = False
          .PreserveFormatting = True
          .RefreshOnFileOpen = False
          .BackgroundQuery = True
          .RefreshStyle = xlInsertDeleteCells
          .SavePassword = False
          .SaveData = True
          .AdjustColumnWidth = True
          .RefreshPeriod = 0
          .PreserveColumnInfo = True
          .ListObject.DisplayName = "axis1"
          .Refresh BackgroundQuery:=False
      End With
      Range("B4").Select
  End Sub
  </code></pre>
  
  <p>I Want to avoid Selection. Though procedure suggest that go to query table any cell and press refresh button.  I believe SO Experts posts on related matter must be right and I am doing something silly, due to my elementary knowledge of VBA Coding.
  Any help or guidance in this matter is welcome. Would appreciate full related syntax instead of one liners.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I could workout the solution to avoid the selection. Following code line works fine provided <code>B2</code> is a cell in the Query Table.</p>
  
  <pre><code>Sheets("Sheet2").Range("B2").ListObject.QueryTable.Refresh BackgroundQuery:=False
  </code></pre>
  
  <p>However, If someone has a better solution , it is welcome.</p>