title: Access to excel through VBA, number display error
body: <p>I have created a small VBA code to export data from access to excel, when it is exported all the number formats are displayed as date in excel. I checked format in Access database its right. Could you please tell me how to display them as numbers. All the columns which are number are displayed as Date so it would be great if that code line checks for all the columns and display the correct/default format.</p>
  
  <p>For reference my code,</p>
  
  <pre><code>Private Sub Command4_Click()
  
  
   'Defining database variable
    Dim dbnxair As DAO.Database
    'Defining Excel variable
     Dim excelnxair As Excel.Application
    'Defining workbook variable
    Dim wrkbooknxair As Excel.Workbook
   'Defining Worksheets
   Dim wrksheetnxair As Excel.Worksheet
  'Defining recordset
   Dim recsetnxair As Recordset
  'Defining Querydef
   Dim querynxair As QueryDef
   'Defining query as string
   Dim strSQL As String
   'Defining condition string
  Dim strlistcondition As String
  
  
  'Opening the database
   Set dbnxair = CurrentDb()
  
  'Creating the Excel object
  Set excelnxair = CreateObject("Excel.Application")
   'Opening the worksheet
    excelnxair.Visible = True
  
    'Creating a new workbook
   Set wrkbooknxair = excelnxair.Workbooks.Add
   wrkbooknxair.SaveAs "C:\Users\z003cnxt\Desktop\new1.xls"
  
    'Creating a new worksheet
   Set wrksheetnxair = excelnxair.Sheets(1)
  
   'Creating a query
  Set querynxair = dbnxair.CreateQueryDef("")
  
   For Each varItem In Me!List2.ItemsSelected
     strlistcondition = strlistcondition &amp; ",'" &amp; Me!List2.ItemData(varItem) &amp; "'"
  Next varItem
  
  strlistcondition = Right(strlistcondition, Len(strlistcondition) - 1)
  
  strSQL = "SELECT * FROM [Std Table] WHERE ([Std Table].Country IN(" &amp; strlistcondition    &amp; "));"
  
  'Adding Sql statement
   querynxair.SQL = strSQL
  
  
  
  'Creating and opening the recordset
   Set recsetnxair = querynxair.OpenRecordset()
  
    'Copying data to excel sheet
    excelnxair.Cells.CopyFromRecordset recsetnxair
  
  
    'Adding field names in each columns
   For lvlcolumn = 0 To recsetnxair.Fields.Count - 1
     excelnxair.Cells(1, lvlcolumn + 1).Value = recsetnxair.Fields(lvlcolumn).Name
   Next
  
   wrksheetnxair.Cells.AutoFilter
  wrksheetnxair.Cells.EntireColumn.AutoFit
  
  
    Set dbnxair = Nothing
   Set recsetnxair = Nothing
    Set querynxair = Nothing
   Set wrkbooknxair = Nothing
  Set wrksheetnxair = Nothing
  Set excelnxair = Nothing
  
  For Each varItem In Me!List2.ItemsSelected
    Me!List2.Selected(varItem) = False
  Next varItem
  
  
  End Sub
  </code></pre>