title: CopyFromRecordset incorrectly formats cells as Date?
body: <p>I have an excel sheet that loads data from a database, then puts it in an Excel Table using the CopyFromRecordset VBA command.  My problem is, a number of cells (which should be integers) keep getting formatted as a date, no matter what I do.  I've changed the number format in Excel to Number, but whenever I reload data from the database, the format switches back to date.</p>
  
  <p>The datatype in the database is Integer, and yet, when I load data from the DB, Excel still changes the cell format to Date.  Even if an end-user enters an integer into the cell after loading data, excel changes it to a date.  For example, if I enter 5 into the cells, excel changes it to 1/5/1900.</p>
  
  <p>Why would Excel keep changing these cells to dates, even after the format dropdown is changed to something else?</p>
  
  <p>Things I've tried:</p>
  
  <ul>
  <li><p>Changed the format from date to number, general, &amp; text.  It reverts to Date on CopyFromRecordset</p></li>
  <li><p>deleting the column and making a new one formatted as Number.  It still reverts on CopyFromRecordset</p></li>
  <li><p>Cast the datatype to integer in the select statement</p></li>
  </ul>
  
  <p>Any other ideas?</p>
  
  <p>A portion of the VBA code that loads the data from the database:</p>
  
  <pre><code>SQLStr = "Select ......, [SO] FROM v_TRACKING"
  Set Cn = New ADODB.Connection
  Cn.Open "Driver={SQL Server Native Client 11.0};Server=" &amp; Server_Name &amp; ";Database=" &amp; Database_Name &amp; ";Trusted_connection=yes;"
  rs.Open SQLStr, Cn, adOpenStatic
  
  dataRange = "a13:az" &amp; (rs.RecordCount + 12)
  
  With ActiveSheet.Range(dataRange)
      .ClearContents
      .CopyFromRecordset rs
  End With
  </code></pre>
  
  <p>All other columns stay formatted correctly, but for some reason the SO column gets formatted as a date.  I've been banging my head against a wall about this for a few days now, so <em>any</em> ideas would be appreciated :)</p>