How to convert multiple CSV files to Excel

Posted On November 24, 2019

The CSV format is a spreadsheet format, quite popular among office workers, especially accountants, because of the convenience of preserving function structures, and previously executed commands, but the capacity is quite good. light. However,CSV files from the Internet to the computer and manipulating on Microsoft Excel sometimes have errors, as well as not being able to use all the tools and support on the Excel application. Therefore, ftoday danny2507blog will share with you a little tip on converting multiple CSV files into XLS or XLSX right on Excel application by VBA code.

Method 1: Convert CSV files to Excel in VBA

Convert CSV files to Excel in VBA (XLS format)

Step 1: First, open your Excel application. Here, select the Developer tab and click on Visual Basic . Or you can also press Alt + F11 to open the VBA code editor.

Step 2: The Microsoft Visual Basic for Applications dialog box opens. Here you select the menu Insert and then click Module.

Step 3: copy & paste the following code….

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
ActiveWorkbook.SaveAs Replace(xSPath & xCSVFile, “.csv”, “.XLS”, vbTextCompare), xlNormal
ActiveWorkbook.Close
Windows(xWsheet).Activate
xCSVFile = Dir
Loop
Application.StatusBar = False
Application.DisplayAlerts = True
End Sub

Paste in the Module1 dialog box (Code) and then click Run , or press the F5 key to execute. 

Step 4: Next, the Select a Folder dialog box appears, here you go to the folder containing the CSV file, click and click OK to Excel to conduct the Convert file in batch.       

Step 5: And here is the result, XLS files are in the Folder of the CSV file. 

Convert CSV to XLSX file with VBA code

In addition to converting the CSV file into Excel 97-2003 format as above. To batch convert CSV files into XLSX format of Microsoft Excel 2007 and above, you do the same.    

The only difference is to replace the above code with the code below => and press Run or F5 on the keyboard in the dialog box Microsoft Visual Basic for Applications to run:

Sub CSVtoXLSX()
‘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
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

How to convert a CSV file to Excel online

In addition to using the code that I have just detailed above, you can also use how to convert CSV files to Excel with online tools quickly.

  • Step 1: You access this address: https://convertio.co/vn/csv-xls/ => Then click Ch o n t é p message to download a CSV file from your computer on.     
  • Step 2: Then you click Convert.
  • Step 3: after the conversion finished, you press the download is finished.   

Generally, these online conversion sites I think anyone can use is simple. The process is as simple as downloading the file to be converted, then click convert, and download the converted file is done.

Every page is the same!

In addition to the above website, there are also some websites that also support the ability to convert CSV format to Excel online as well, including:

  •                     https://www.zamzar.com/convert/csv-to-xls/
  •                     https://onlineconvertfree.com/en/convert-format/csv-to-xls/
  •                     You add more if any okay …………………………………………… ..

Written by admin

Related Posts

How to convert multiple CSV files to Excel

How to convert multiple CSV files to Excel

The CSV format is a spreadsheet format, quite popular among office workers, especially accountants, because of the convenience of preserving function structures, and previously executed commands, but the capacity is quite good. light. However,CSV files from the...

How to Set Password for PowerPoint file

How to Set Password for PowerPoint file

With Office tools, you have the option of creating a password to protect the content, preventing people create duplication of your content. With PowerPoint, we can completely set a password to protect the content in the presentation. Setting a password for a...

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *