title: Delete unwanted queries in VBA
body: <p>How do I delete all unwanted queries from the workbook?</p>
  
  <pre><code>Sub DeleteQuery()
      Dim queries As Variant
      queries = Array("q1", "q2", "q3")
      For Each qr In ThisWorkbook.queries
          'Not sure about the syntax of the following line
          If qr not in queries Then
          qr.Delete
      Next qr
  End Sub
  </code></pre>
  
  <p>If the query is not in the list, then it should be deleted</p>
  
  <pre><code>ActiveWorkbook.Queries("Query1").Delete
  </code></pre>
  
  <p>will not work, because the name of the unwanted queries are unclear</p>