user2653322
user2653322

Reputation: 117

Excel Macro - Export sheets to windows comma separated CSV

I've got this working, except I need the resulting files to be specifically a 'windows comma separated CSV' file. Any ideas how to specify this?

Sub asdf()
    Dim ws As Worksheet, newWb As Workbook

    Application.ScreenUpdating = False
    For Each ws In Sheets(Array("sheet1", "sheet2"))
       ws.Copy
       Set newWb = ActiveWorkbook
       With newWb
          .SaveAs ws.Name & ".csv", xlCSV
          .Close (False)
       End With
    Next ws
    Application.ScreenUpdating = True
End Sub

Upvotes: 2

Views: 740

Answers (1)

luke_t
luke_t

Reputation: 2985

It should be as easy as specifying the FileFormat as CSVWindows

.SaveAs ws.Name & ".csv", xlCSVWindows

Upvotes: 3

Related Questions