title: Excel SQL - Value from column / range cells
body: <p>I'm trying to retrieve data from column A (cell A1 to A20000) from sheet <code>data</code>. When I put this query i get error: "Unexpected extra token <code>Dim</code>". What I do wrong?</p>
  
  <pre><code>SELECT 
      OZATI_etc.Account, 
      OZATI_etc.Equipment
  FROM 
      OZATI_etc
  WHERE 
      OZATI_etc.Account IN (SELECT * FROM [data$A1:A20000])
  ORDER BY
      OZATI_etc.Account
  
      Dim currentRow As Integer
      Dim str As String
      currentRow = 1
      Do While (sheets("data").Range("A" &amp; currentRow).Value &lt;&gt; "")
          str = str &amp; ",'" &amp; sheets("data").Range("A" &amp; currentRow).Value &amp; "'"
          currentRow = currentRow + 1
      Loop
      str = Mid(str, 2)
  </code></pre>