I have an Excel sheet with two columns, like this:
53400 10
53480 1
53470 1
53460 1
53450 1
53440 1
I would like save a new .csv
file using a vba macro:
Application.SheetsInNewWorkbook = 1
Worksheets("CSV").Range("A:B").Copy
Workbooks.Add
ActiveSheet.Paste
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:=ThisWorkbook.Path & "\file.csv", FileFormat:=xlCSV, CreateBackup:=False
ActiveWorkbook.Close False
Application.DisplayAlerts = True
Worksheets("CSV").Range("A:B").ClearContents
The problem is that I get a .csv
file comma separated, like this:
53400,10
53480,1
53470,1
53460,1
53450,1
53440,1
And what I want is aa .csv
file with one value in each cell, like the original data (I can get something like this saving manually):
53400 10
53480 1
53470 1
53460 1
53450 1
53440 1
The problem was the list separator. I had to use ";" instead of ",". I could configure it by adding Local:=True when saving the workbook. You could also force the list separator to be ";" using another command.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.