Hi All,I need your help with following case. I build a macro, which have to save the data as csv file, which can be used by other application.Everything is working except saving part. During saving as CSV I see in results file that every line of data is in quotes "...".The problem occurs in Italian language setting, when I set English everything is fine... its totally weird.
The code is creating from several columns text file delimited with ; and then save as CSV, how its possible that its related to language setting and how to fix it? Thanks
Code:
Sub Save_file()
Dim wb, NewWb As Workbook
Dim ws As Worksheet
Dim nCol, nRow As Integer
Dim s As String
Dim LastRow As Integer
Set wb = ThisWorkbook
Set ws = wb.Sheets("RESULT")
wb.Saved = True
ws.Range("A1").CurrentRegion.Copy
ws.Range("A1").PasteSpecial xlPasteValues
LastRow = ws.Range("A" & Rows.Count).End(xlUp).row
Set NewWb = Workbooks.Add
'convert columns to text
For nRow = 1 To LastRow
nCol = 1
Do Until ws.Cells(nRow, nCol).Value = ""
If (s = "") Then
s = ws.Cells(nRow, nCol).Value
Else
s = s & ";" & ws.Cells(nRow, nCol).Value
End If
nCol = nCol + 1
Loop
NewWb.Sheets(1).Cells(nRow, 1).Value = s
s = ""
Next nRow
Application.DisplayAlerts = False
NewWb.SaveAs Filename:=ThisWorkbook.Path & "\IMPORT\" & "FILE.csv", FileFormat:=xlCSV, Local:=True
NewWb.Close
wb.Close = False
Application.DisplayAlerts = True
End Sub
The code is creating from several columns text file delimited with ; and then save as CSV, how its possible that its related to language setting and how to fix it? Thanks
Last edited: