Trying to save to csv or txt without applying "" to strings containing comma values

Roxenham

New Member
Joined
Feb 15, 2024
Messages
2
Office Version
  1. 365
Platform
  1. Windows
As the subject states I am trying to use VBA to save several sheets as separate csv files though when I do output files contain quotes around the strings

VBA -

Sub SaveSheetAsCSV()
Dim ws As Worksheet
Dim csvFile As String

For Each ws In Worksheets
ws.Copy
csvFile = "C:\Users\Richa\Desktop\New folder (2)\" & ws.Name & ".csv"
Application.ActiveWorkbook.SaveAs Filename:=csvFile, _
FileFormat:=xlCSV, CreateBackup:=False
Application.ActiveWorkbook.Saved = True
Next

End Sub

Input example :

Screenshot 2024-02-16 000516.png


Output example :

Screenshot 2024-02-16 000527.png
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
I'm no VBA expert but I presume you should concatenate the two fields to somewhere else and export to CSV
 
Upvote 0
Thank you for the response unfortunately I am just getting the quotations around the entire string following a concatenate

1708075696603.png
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top