title: Conversion of csv to xslx and adding column using macro
body: <p>I have a list of about 400 files in CSV format I want to convert them into XLSX format. also I want to add a new column to the left while converting and want to add first 8 characters only of the file name to the newly added column. Suppose the file name is "<code>TZ125250 April 26 2015.csv</code>" it should add <code>TZ125250</code> to the first column until the last row where data exist in the spreadsheet and should save as "<code>TZ125250 April 26 2015.xlsx</code>", most CSV files have data around 200000 rows. the code I am using is</p>
  
  <pre><code>Sub CSVtoXls()
  
   Dim CSVfolder As String
   Dim XlsFolder As String
   Dim fname As String
   Dim wBook As Workbook
  
   CSVfolder = "C:\csvfolder\"
   XlsFolder = "C:\xlsFolder\"
  
   fname = Dir(CSVfolder &amp; "*.csv")
  
   Do While fname &lt;&gt; ""
      Set wBook = Workbooks.Open(CSVfolder &amp; fname, Format:=6, Delimiter:=",")
  
      Cells.Select
      Cells.EntireColumn.AutoFit
      Columns("A:A").Select
      Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
  
      wBook.SaveAs XlsFolder &amp; Replace(fname, ".csv", ""), ThisWorkbook.FileFormat
      wBook.Close False
      fname = Dir
   Loop
  
  End Sub
  </code></pre>
  
  <p>This code converts CSV to XLSX if I remove this section</p>
  
  <pre><code>Cells.Select
  Cells.EntireColumn.AutoFit
  Columns("A:A").Select
  Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
  </code></pre>