Hello,
I've created (pieced it together from solutions found on this forum) a looped VBA code that currently makes a copy of all the non excluded sheets in the workbook, exports each sheet as a separate workbook, and saves them as a CSV file using the sheet name as the file name.
However, the end result adds quotation marks ("text,number") to the text.
There are no problems if I do these steps manually (no quotation marks).
I found that replacing "WS.Copy" with "WS.Move" also creates a file without the quotations marks, however, it also crashes while running the FileName step (Run-time error '2417221080 (800401a8) | Automation error)
I am no expert, so I would appreciate any tips on how to make this work or if there are better ways of doing this.
I've created (pieced it together from solutions found on this forum) a looped VBA code that currently makes a copy of all the non excluded sheets in the workbook, exports each sheet as a separate workbook, and saves them as a CSV file using the sheet name as the file name.
However, the end result adds quotation marks ("text,number") to the text.
There are no problems if I do these steps manually (no quotation marks).
I found that replacing "WS.Copy" with "WS.Move" also creates a file without the quotations marks, however, it also crashes while running the FileName step (Run-time error '2417221080 (800401a8) | Automation error)
I am no expert, so I would appreciate any tips on how to make this work or if there are better ways of doing this.
VBA Code:
Sub Export()
'
' Export Macro
'
Dim WB As Workbook
Dim WS As Worksheet
Dim FolderPath As String
Dim FileName As String
FolderPath = "K:\censored_path_name"
For Each WS In Worksheets
If WS.Name <> "Sheet name 1" And WS.Name <> "Sheet name 2" And WS.Name <> "Sheet name 3" And WS.Name <> "Sheet name 4" And WS.Name <> "Sheet name 5" Then
WS.Copy
Set WB = ActiveWorkbook
FileName = WS.Name
WB.SaveAs FileName:=FolderPath & "\" & FileName & ".csv", FileFormat:=xlCSVUTF8, CreateBackup:=False
Application.DisplayAlerts = False
WB.Close
Application.DisplayAlerts = True
End If
Next WS
End Sub
Last edited by a moderator: