I need to save some sheets in the workbook as .cvs.
When I do it manually it saves the file as .cvs and when I open the file it shows the data in columns but when i do it with a macro it saves the file as .cvs but when I open the files it shows the columns in one column with commas as separator.
This is my code so far:
Sub Crea_Libros_Cargar()
' se encargara de recorrer todas las hojas
Dim W As Integer
'variables para las rutas
Dim Nombre, RutaGuardar As String
Dim Nombresuc As String
Dim Nombrecd As String
Nombresuc = InputBox("Sucursal")
Nombrecd = InputBox("CD")
'creo un ciclo for recorriendo todas las hojas del archivo actual
For W = 1 To ActiveWorkbook.Sheets.Count
'activo la primera hoja
Sheets(W).Activate
'asigno el nombre de la hoja a la variable
Nombre = ActiveSheet.Name
Sheets(Nombre).Copy
RutaGuardar = "C:\Users\carolina.urra\Documents\Distribucion\Sugerido Distribucion\MACRO\" & Nombresuc & Nombrecd & Nombre & ".csv"
'
ActiveWorkbook.SaveAs Filename:=RutaGuardar, FileFormat:=xlCSV, CreateBackup:=False
ActiveWindow.Close Savechanges:=True
Next
MsgBox ("proceso finalizado exitosamente") _
, , "Finalizado"
End Sub
Can someone please help me to save the files the same way when I do it manually.
Here its what I Get when i record the saving process:
Sheets("1").Select
Sheets("1").Name = "1"
Sheets("1").Select
Sheets("1").Copy
ActiveWorkbook.SaveAs Filename:= _
"C:\Users\carolina.urra\Documents\Distribucion\Sugerido Distribucion\MACRO\Libro24.csv" _
, FileFormat:=xlCSV, CreateBackup:=False
ActiveWorkbook.Save
ActiveWindow.Close
Bookmarks