title: VBA to include SQL query headers
body: <p>I need to add the table headers to include in my VBA code, which is connected to SQL. The code is working (as it's spitting out the SQL results on a new worksheet), however it's not grabbing the headers.</p>
  
  <p>Can someone help?</p>
  
  <pre><code>Sub SpectrumADGroupMapping()
  
      'Start Declarations'
      Dim Cn As ADODB.Connection
      Dim rs As ADODB.Recordset
  
      'Connection string to SQL server/DB (Windows Auth)
      Set Cn = New ADODB.Connection
      Cn.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=True;Data Source=TEST;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=TESTPC;Use Encryption for Data=False;Tag with column collation when possible=False;Initial Catalog=TESTDBNAME"
      Cn.Open 
  
      Set and Execute SQL Command
      Set rs = New ADODB.Recordset
      rs.ActiveConnection = Cn
      rs.Open "Select top 50* from TestTable order by creationDate desc"
  
      'Copy Data to Excel
      Worksheets.Add(After:=Worksheets(1)).Name = "TestWorkSheet"
      Range("A2").CopyFromRecordset rs
  
      Cn.Close
  
  End Sub
  </code></pre>