0

so I have one big Excel sheet (.xlsm) from which I want to get 3 new CSV files. I already tried something like that below, but this seperates with normal commas:

Sub walrus()

Dim dir As String
dir = "My\Super\Cool\Path.csv"

Application.DisplayAlerts = False

ThisWorkbook.Sheets("FooBar").Copy
ActiveWorkbook.SaveAs Filename:=dir, FileFormat:=xlCSV, CreateBackup:=True
ActiveWorkbook.Close

Application.DisplayAlerts = True

End Sub

So does anybody know how to change that?

Thanks guys!

braX
  • 11,506
  • 5
  • 20
  • 33
Lukas
  • 3
  • 2
  • SaveAs in xlCSV follows the system-set locale, so you may get comma, others semicolon. Excel also chooses to quote or not depending on content, and numbers may be changed from 123456798 to 1.23E... You are better off handling each cell individually. There are several examples here and over at SuperUser. [Like this](https://stackoverflow.com/questions/37037934/excel-macro-to-export-worksheet-as-csv-file-without-leaving-my-current-excel-sh) – MyICQ Jul 27 '22 at 06:49

1 Answers1

0

Thanks for the help, I got it working just by adding Local:=true to the copy line no idea what it dows, but it works Maybe this helps anybody

Lukas
  • 3
  • 2
  • 1
    When using `Local:=True`, VBA will use the *List separator* character of your computer (can be found in the Additional settings of the Region Settings). Be aware that this might be different on other computers. – FunThomas Jul 27 '22 at 08:04