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

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

Steps:

  • From the Data tab >>> select From Text/CSV.

The Import Data dialog box will open.

  • Select the file named “convert-csv-to-xlsx.csv” and click Import.

convert csv to xlsx without opening

A new window will appear.

  • From Load >>> select “Load To…”.

Select the output location.

  • Click on “Existing worksheet:” and point to cell A1.
  • Click OK.

convert csv to xlsx without opening

The CSV file will be converted to XLSX file format.

Read More: How to Convert CSV to XLSX


Method 2 – Convert CSV to XLSX without Opening by Using Legacy Wizard

Steps:

  • Press ALT + F + T to bring up the Excel Options window.
  • From Data >>> check “From Text (Legacy)” and click OK.

convert csv to xlsx without opening

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

Import the file again.

convert csv to xlsx without opening

The Text Import Wizard window will pop up.

  • Check “My data has headers” and click on Next.

  • Choose Comma as Delimiter and click Next.

convert csv to xlsx without opening

  • Click on Finish.

Set the output location as cell A1 in Sheet2.

  • Click OK.

convert csv to xlsx without opening

The final output will be as shown in the following image.

Read More: Convert CSV to Excel Automatically


Method 3 – Convert CSV to XLSX without Opening by Using VBA Code

We’ll use VBA code to convert CSV files. We will define our input and output files. However, this code is only for a single file.

Steps:

  • Select the file and from the Home tab >>> select Copy path.

This will copy the location of the file.

  • Open the Module window and enter 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

  • We have used the Sub Procedure as CsvToXlsxConversion2.
  • Declaring our variable types.
  • We’re defining our input file using the Set Statement.
    We’ve got our file location via the Copy path option.
  • We’re setting our output file as “xlsx” and the file format as xlWorkbookDefault, which is XLSX format.

convert csv to xlsx without opening

  • Save and Run the Module.

The CSV file will be converted to XLSX.

convert csv to xlsx without opening

Read More: How to Convert CSV to Excel with Columns


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

Steps:

  • From the Developer tab >>> select Visual Basic.

convert csv to xlsx without opening

  • From Insert >>> select Module.

 

  • Enter 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

  • We’re naming our Sub Procedure CsvToXlsxConversion.
  • We’re declaring our variable types.
  • We’re displaying the InputBox to pick a folder.
  • The code will search for all CSV files in that folder.
  • We’re using the Do While Loop to convert all CSV files.

convert csv to xlsx without opening

  • Save the Module.
  • Click anywhere in the code and press Run.

It will ask to select a folder.

  • Select a folder and click OK.

convert csv to xlsx without opening

We have two files with XLSX format in that folder (it can vary depending on the number of CSV files you have in that folder).

Open any file to check if the data conversion has been done correctly.

convert csv to xlsx without opening

Read More: Difference Between CSV and Excel Files


Method 5 – Utilizing Command-Line to Convert CSV to XLSX

Steps:

  • Enter 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.

  • We’re setting two arguments.
  • We’re defining the input file. Moreover, the first Worksheet is used in our code only.
  • We’re setting the cell
  • We’re using Autofit.\
  • We’re making the first row Bold.
  • We’re saving the file as 51 (this means XLSX).
  • Select All Files in “save as type:”.
  • Save it as “vbs” filename.

convert csv to xlsx without opening

  • From the Start Menu >>> open Command Prompt.

  • Enter the following code and press ENTER.
CD "C:\Users\USER\Desktop\Exceldemy"

This will set our directory to our working folder.

  • Add 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.

  • Press ENTER.

convert csv to xlsx without opening

Open the “converted-using-cmd.xlsx” file to verify it.

Read More: How to Import CSV Data into Excel


Convert CSV Incorporating Online Converter

You can also use websites like Cloud Convert to convert your file.

Steps:

  • Go to the website.
  • Select your file.

convert csv to xlsx without opening

  • Click on Open.

  • Select XLSX as the output format and click on Convert.

convert csv to xlsx without opening

  • Click on Download.

The output will look like the image below.

convert csv to xlsx without opening

Read More: How to Convert CSV to XLSX Command Line


Download Practice Workbook


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