How to Convert CSV to XLSX without Opening (5 Easy Methods)

Often, we get our files in CSV format. That file format is not very user-friendly. In this article, we’re going to show 6 methods to convert CSV to XLSX without opening. To demonstrate our techniques, we’ve chosen a dataset with 3 columns: “Name”, “Email”, and “Birth Year”.

convert csv to xlsx without opening


How to Convert CSV to XLSX without Opening: 5 Easy Ways

1. Use of Text Import Wizard to Convert CSV to XLSX without Opening

For the first method, we’re going to use the Text Import Wizard to convert CSV to XLSX format.

Steps:

  • Firstly, from the Data tab >>> select From Text/CSV.

The Import Data dialog box will appear.

  • Secondly, select the file named “convert-csv-to-xlsx.csv”, and press Import.

convert csv to xlsx without opening

A new window will appear.

  • Thirdly, from Load >>> select “Load To…”.

Here, we’ll select our output location.

  • Then, click on “Existing worksheet:” and point to cell A1.
  • Finally, press OK.

convert csv to xlsx without opening

Thus, we’ll convert our CSV file to XLSX.

Read More: How to Convert CSV to XLSX


2. Convert CSV to XLSX without Opening by Using Legacy Wizard

In this section, we’re going to use a Legacy Wizard to convert our file from CSV to XLSX.

Steps:

  • Firstly, press ALT + F + T to bring up the Excel Options window.
  • Secondly, from Data >>> put a tick mark on “From Text (Legacy)” and press OK.

convert csv to xlsx without opening

  • Thirdly, from the Data tab >>> Get Data >>> Legacy Wizards >>> select From Text (Legacy).

Now, we’ll Import our file again.

convert csv to xlsx without opening

After that, the Text Import Wizard window will appear.

  • Then, put a tick mark on “My data has headers”, and click on Next.

  • After that, choose Comma as Delimiter, and press Next.

convert csv to xlsx without opening

  • Then, click on Finish.

Then, we’ll set our output location as cell A1 in Sheet2.

  • Finally, press OK.

convert csv to xlsx without opening

In conclusion, we’ll solve our problem using this method. Moreover, this is what the final step should look like.

Read More: Convert CSV to Excel Automatically


3. Convert CSV to XLSX without Opening by Using VBA Code

In this method, we’ll use another VBA code to convert CSV files. Here, we’re going to define our input and output files, and this code is for a single file only.

Steps:

  • Firstly, select our file and from the Home tab >>> select Copy path.

This will copy the location of our file.

  • Secondly, as shown in the third method, bring up the Module window and type the following code.
Sub CsvToXlsxConversion2()
Dim w As Workbook
  Set w = Workbooks.Open("C:\Users\Rafi\OneDrive\Desktop\Softeko\36\convert-csv-to-xlsx.csv")
  w.SaveAs Filename:="C:\Users\Rafi\OneDrive\Desktop\Softeko\36\convert-csv-to-xlsx.xlsx", _ 
      FileFormat:=xlWorkbookDefault, _ 
      ReadOnlyRecommended:=False, CreateBackup:=False
End Sub

VBA Code Breakdown

  • Firstly, we’re calling our Sub Procedure CsvToXlsxConversion2.
  • Secondly, declaring our variable types.
  • Thirdly, we’re defining our input file using the Set Statement.
    Here, we’ve got our file location via the Copy path option.
  • Finally, we’re setting our output file as “converted.xlsx” and the file format as xlWorkbookDefault, which means XLSX format.

convert csv to xlsx without opening

  • Finally, Save and Run the Module.

Thus, we’ve shown you yet another method of converting CSV files to XLSX.

convert csv to xlsx without opening

Read More: How to Convert CSV to Excel with Columns


4. Applying VBA Code to Convert Multiple CSV Files to XLSX without Opening

We’re going to use Excel VBA to convert CSV files. Here, we’ll select a folder in this method, moreover, this code can convert every file inside that folder. Without further ado, let’s jump into the action.

Steps:

Here, we’ll bring up the Module window inside Visual Basic.

  • Firstly, from the Developer tab >>> select Visual Basic.

convert csv to xlsx without opening

  • Secondly, from Insert >>> select Module.

This is where we’ll write our code.

  • Thirdly, type the following code.
Sub CsvToXlsxConversion()
Dim f As FileDialog
Dim fPath As String
Dim csvFile As String
Dim ws As String
Application.DisplayAlerts = False
Application.StatusBar = True
ws = ActiveWorkbook.Name
Set f = Application.FileDialog(msoFileDialogFolderPicker)
f.Title = "Select a folder:"
If f.Show = -1 Then
fPath = f.SelectedItems(1)
Else
Exit Sub
End If
If Right(fPath, 1) <> "\" Then fPath = fPath + "\"
csvFile = Dir(fPath & "*.csv")
Do While csvFile <> ""
Application.StatusBar = "Converting: " & csvFile
Workbooks.Open Filename:=fPath & csvFile
ActiveWorkbook.SaveAs Replace(fPath & csvFile, ".csv", ".xlsx", vbTextCompare), xlWorkbookDefault
ActiveWorkbook.Close
Windows(ws).Activate
csvFile = Dir
Loop
Application.StatusBar = False
Application.DisplayAlerts = True
End Sub

VBA Code Breakdown

  • Firstly, we’re calling our Sub Procedure CsvToXlsxConversion.
  • Secondly, declaring our variable types.
  • Thirdly, we’re displaying the InputBox to pick a folder.
  • Then, the code looks for all CSV files in that folder.
  • Finally, we’re using the Do While Loop to convert all CSV files.

convert csv to xlsx without opening

  • Then, Save the Module.
  • After that, click anywhere in the code and press the Run button.

It will ask us to select a folder.

  • Finally, select a folder, and press OK.

convert csv to xlsx without opening

We’ll see two files with XLSX format in that folder.

Moreover, we can open any file to make sure our data conversion is OK.

convert csv to xlsx without opening

Read More: Difference Between CSV and Excel Files


5. Utilizing Command-Line to Convert CSV to XLSX

In this section, we’re going to use the Command Prompt to convert CSV files.

Steps:

  • Firstly, type the following code in the notepad.
sourceFile= Wscript.Arguments(0)
targetFile = Wscript.Arguments(1)
On Error Resume Next
Set tExcel = GetObject(,"Excel.Application")
If Err.Number = 429 Then
Set tExcel = CreateObject("Excel.Application")
End If
tExcel.Visible = false
tExcel.displayalerts=false
Set tWorkbook = tExcel.Workbooks.open(sourceFile)
Set tWorksheet1 = tWorkbook.Worksheets(1)
Set tRange = tWorksheet1.UsedRange
tRange.EntireColumn.Autofit()
tExcel.Rows(1).Font.Bold = TRUE
tWorksheet1.SaveAs targetFile, 51
tExcel.Quit()

VBS Code Breakdown

This is the Visual Basic scripting edition code.

  • Firstly, we’re setting two arguments.
  • Secondly, we’re defining the input file. Moreover, the first Worksheet is used in our code only.
  • Thirdly, we’re setting the cell range.
  • Then, we’re using Autofit.
  • After that, we’re making the first row Bold.
  • Finally, we’re saving the file as 51 (this means XLSX).
  • Secondly, select All Files in “save as type:”.
  • Thirdly, Save it as “conversion.vbs” filename.

convert csv to xlsx without opening

  • Then, from the Start Menu >>> open Command Prompt.

  • After that, type this code and press ENTER.
CD "C:\Users\USER\Desktop\Exceldemy"

This will set our directory to our working folder.

  • Then, type this code.
conversion "C:\Users\USER\Desktop\Exceldemy\convert-csv-to-xlsx.csv" "C:\Users\USER\Desktop\Exceldemy\converted-using-cmd.xlsx"

This code will run our “conversion.vbs” file. In our code, the first location is the input and the second one is the output file.

  • Finally, press ENTER.

convert csv to xlsx without opening

Then, we can open our “converted-using-cmd.xlsx” file to verify everything. We’ll see if everything worked as expected.

Read More: How to Import CSV Data into Excel


Convert CSV Incorporating Online Converter

For the last method, we can use any online converter. Here, we’re gonna use the website Cloud Convert to convert our file.

Steps:

  • Firstly, go to the website.
  • Secondly, select our file.

convert csv to xlsx without opening

  • Thirdly, select our file and click on Open.

  • Then, select XLSX as our output format and press Convert.

convert csv to xlsx without opening

  • Finally, click on Download.

In conclusion, you can convert your CSV files via online tools too and this is what the final step should look like.

convert csv to xlsx without opening

Read More: How to Convert CSV to XLSX Command Line


Download Practice Workbook


Conclusion

We’ve shown you 5 methods to convert CSV to XLSX without opening. If you face any problems regarding any of the methods, feel free to comment below. Thanks for reading, keep excelling!


Related Articles


<< Go Back to How to Convert CSV to Excel | Import CSV to Excel | Importing Data in Excel | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Rafiul Haq
Rafiul Haq

Rafiul Haq worked as an Excel and VBA Content Developer in Exceldemy for over two years and published almost 200 articles for the website. He is passionate about exploring new aspects of Excel and VBA. He received his Bachelor of Science in Mechanical and Production Engineering (MPE) from the Islamic University of Technology. Rafiul furthered his education by obtaining an MBA in Finance from the Institute of Business Administration (IBA) at the University of Dhaka. Apart from creating... Read Full Bio

4 Comments
  1. The below works fine for me and is what i’ve been looking for, but how do i get it to set all columns to text?

    Thank you.

    sourceFile= Wscript.Arguments(0)
    targetFile = Wscript.Arguments(1)
    On Error Resume Next
    Set tExcel = GetObject(,”Excel.Application”)
    If Err.Number = 429 Then
    Set tExcel = CreateObject(“Excel.Application”)
    End If
    tExcel.Visible = false
    tExcel.displayalerts=false
    Set tWorkbook = tExcel.Workbooks.open(sourceFile)
    Set tWorksheet1 = tWorkbook.Worksheets(1)
    Set tRange = tWorksheet1.UsedRange
    tRange.EntireColumn.Autofit()
    tExcel.Rows(1).Font.Bold = TRUE
    tWorksheet1.SaveAs targetFile, 51
    tExcel.Quit()

    • Reply Bishawajit Chakraborty
      Bishawajit Chakraborty Dec 18, 2022 at 10:56 AM

      Thank you so much JOHN JOYCE for your comment. To set all the columns into text, you can follow the below steps accordingly.

      • Firstly, click on the General option from the Home tab.

      • Then, choose the Text option after selecting your entire data set. After that, you will get your desired result.

      After changing the format save the file and re-open it to check whether the data shows in the proper format.

      Best Regards,
      Bishwajit
      Team ExcelDemy

  2. Is there a quick way to make any of these work with multiple files in subfolders?

    • Hello M,
      Thank you for your query. I hope you are doing well. The quickest way to convert CSV files to XLSX files is by using programming languages like Excel VBA. You may check Method 4 ( Applying VBA Code to Convert Multiple CSV Files to XLSX without Opening) to convert multiple files in subfolders.

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo