Hi, not long ago, i asked for help writing a macro that takes my current workbook and saves a copy of a desired sheet as csv. However, i noticed that the csv file that comes out, is quite odd.
The original sheet consists of two columns: A which is a product name, and B which is the stock for that product. The resulting csv copy of that sheet ends up being one column that has "product,stock" on column A, until there is no more data, then it is autocompleted by "," on all cells on that row.
My code thus far looks like this :
Option Explicit Public Sub Exportar_CSV() Dim csvFileName As String csvFileName = GetNextFileName(ThisWorkbook.Path & "\CSV_Discos SS_<n>.csv") ThisWorkbook.Worksheets("CSV").Copy ActiveWorkbook.SaveAs csvFileName, FileFormat:=xlCSV ActiveWorkbook.Close False MsgBox "Archivo guardado como " & csvFileName Sheets("Entradas").Range("A2:A10000").ClearContents Sheets("Salidas").Range("A2:A10000").ClearContents ActiveWorkbook.Save End Sub Private Function GetNextFileName(filePath As String) As String Dim n As Integer n = 0 Do n = n + 1 GetNextFileName = Replace(filePath, "<n>", Format(n, "000")) Loop Until Dir(GetNextFileName) = vbNullString End Function
Can anyone help me make it do a normal copy on csv format with no additional cells?