'saving as csv file keeping columns
I have this code, what I am trying to do is to save data from a excel file to a csv file but when I do this the saved data is automatically saved with commas as you can see here:

I need to save the data from my excel file to a new excel with csv file without adding the commas and maintaining the original columns as you can see here:

The code I've done so far is this:
Sub SaveAs()
Dim wb As Workbook
Dim wb_New As Workbook
Dim wbstring As String
Dim filenamex As String
Set wb = ThisWorkbook
filenamex = InputBox("Add file name", "Add new file name")
wbstring = "C:\FichBCC\"
Set wb_New = Workbooks.Add
wb_New.Worksheets("Sheet1").Range("A1:E2000").Value = wb.Worksheets("Sheet1").Range("A1:E2000").Value
wb_New.SaveAs filename:=wbstring & filenamex & ".csv", FileFormat:=6
End Sub
Solution 1:[1]
I managed to do the code, I just had to add the following: Local:=True so the new code is this one:
Dim wb As Workbook
Dim wb_New As Workbook
Dim wbstring As String
Dim filenamex As String
Set wb = ThisWorkbook
filenamex = InputBox("Ingrese nombre del archivo", "Ingrese el nombre de archivo del nuevo libro")
wbstring = "C:\FichasBCC\"
Set wb_New = Workbooks.Add
wb_New.Worksheets("Hoja1").Range("A1:E2000").Value = wb.Worksheets("Principal").Range("A1:E2000").Value
wb_New.SaveAs filename:=wbstring & filenamex & ".csv", FileFormat:=xlCSV, Local:=True
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | LOUIS SKINNY |
