How To Batch Convert Multiple CSV Files To XLS(X) Files In Excel

Batch Convert CSV Files To XlS(X) Files With Macro Code

To convert multiple CSV files from one folder to XLS(X) files, you can do as below steps:

1. Enable a new workbook, press Alt + F11 keys to open Microsoft Visual Basic for Applications window, and click Insert > Module. See screenshot:
doc batch convert cvs xls 1

VBA: Convert CSV files to XLSX

Sub CSVtoXLS()
'UpdatebyExtendoffice20170814
 Dim xFd As FileDialog
 Dim xSPath As String
 Dim xCSVFile As String
 Dim xWsheet As String
 Application.DisplayAlerts = False
 Application.StatusBar = True
 xWsheet = ActiveWorkbook.Name
 Set xFd = Application.FileDialog(msoFileDialogFolderPicker)
 xFd.Title = "Select a folder:"
 If xFd.Show = -1 Then
 xSPath = xFd.SelectedItems(1)
 Else
 Exit Sub
 End If
 If Right(xSPath, 1) <> "\" Then xSPath = xSPath + "\"
 xCSVFile = Dir(xSPath & "*.csv")
 Do While xCSVFile <> ""
 Application.StatusBar = "Converting: " & xCSVFile
 Workbooks.Open Filename:=xSPath & xCSVFile, Local:=True
 ActiveWorkbook.SaveAs Replace(xSPath & xCSVFile, ".csv", ".xlsx", vbTextCompare), xlWorkbookDefault
 ActiveWorkbook.Close
 Windows(xWsheet).Activate
 xCSVFile = Dir
 Loop
 Application.StatusBar = False
 Application.DisplayAlerts = True
End Sub

here you must pay attention to if you use semicolon separator you should add  ‘Workbooks.Open Filename:=xSPath & xCSVFile, Local:=True’ and change your local format list with a semi-colon’ and you should save it to xlsm format