Answer the question
In order to leave comments, you need to log in
How do I add quotes to text fields that have a space in an Excel save to CSV macro?
Tell me, what condition should be added in this macro so that quotes are added only to text strings that contain more than one word:
Sub SaveAsCSVinQuotes()
Dim r As Range, c As Range, s As String
s = Application.GetSaveAsFilename(, "CSV Files (*.csv),*.csv,All Files (*.*),*.*", , "Save as CSV in quotes")
If s = "False" Then Exit Sub
Open s For Output As #1
For Each r In ActiveSheet.UsedRange.Rows
s = ""
For Each c In r.Cells
s = s & " ;" & """" & c & """"
Next
Print #1, Mid$(s, 2)
Next
Close #1
End Sub
Answer the question
In order to leave comments, you need to log in
=ЕСЛИ(ДЛСТР(СЖПРОБЕЛЫ(A2))=0;0;ДЛСТР(СЖПРОБЕЛЫ(A2))-ДЛСТР(ПОДСТАВИТЬ(A2;" ";""))+1)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question