Solve the misalignment problem of opening csv with excel tools, and convert csv to xls or xlsx files

1. The csv opening method solves the misalignment problem

1.1 Open excel and select the data column.
insert image description here

1.2 Click From Text/CSV to select the file to open.
insert image description here

1.3 Select comma split to load data and open CSV file
insert image description here

2. Convert CSV to xls or xlsx file after opening

2.1 Right-click the cursor on the sheet and select View Code
insert image description here

2.2 Enter the VBA window
insert image description here

2.3 Copy the following code to the code window

将工作簿所有工作表另存为单独的文件。 
路径为原工作簿路径,文件名为工作表名 

Sub Test() 
    Dim Sht As Worksheet 
    For Each Sht In Sheets 
        Sht.Copy 
        ActiveWorkbook.SaveAs ThisWorkbook.Path & "\" & Sht.Name & ".xlsx" 
        ActiveWorkbook.Close 
    Next 
End Sub

insert image description here

2.4 Click to run
insert image description here

2.5 The exported sheet will be stored in the original folder with the original sheet name
insert image description here

Guess you like

Origin blog.csdn.net/weixin_42597632/article/details/131413532