Hey everybody,
I'm trying to write a macro that will export one of the sheets from workbook as csv file. The sheet I want to export looks like this (picture 1). The problem I have is that I always get double quotes around my text when I open a exported csv file (picture 2). This is the macro that I use to create that csv file.
Any suggestion how to solve this problem?
-------------------------------------------------------------------------------------------
MOD EDIT: Added code tag.
I'm trying to write a macro that will export one of the sheets from workbook as csv file. The sheet I want to export looks like this (picture 1). The problem I have is that I always get double quotes around my text when I open a exported csv file (picture 2). This is the macro that I use to create that csv file.
Code:
Sub Export_fak()
Application.DisplayAlerts = False
Dim xStr As String
Dim Path As String
Dim filename As String
strpath = Worksheets("Export").Range("J5").Value
filename = Range("AV1")
If Right(strpath, 1) <> Application.PathSeparator Then
strpath = strpath & Application.PathSeparator
End If
Application.ScreenUpdating = False
Sheets.Add After:=ActiveSheet
ActiveSheet.Name = "New fak"
Sheets("Export").Select
Columns("G:I").Select
Selection.EntireColumn.Hidden = False
Range("H4").Select
Selection.Copy
lastrow = Cells(Rows.Count, "C").End(xlUp).Row
Range("H4:H" & lastrow).Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Range("AW1").Select
Selection.Copy
Range("H4").Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Range("A4").Select
Selection.Copy
lastrow = Cells(Rows.Count, "C").End(xlUp).Row
Range("A4:A" & lastrow).Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Range("H4").Select
lastrow = Cells(Rows.Count, "C").End(xlUp).Row
Range("H4:H" & lastrow).Select
Selection.Copy
Sheets("New fak").Select
Range("A1").Select
xStr = ""
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("A1").Select
Sheets("New fak").Copy
ActiveWorkbook.SaveAs filename:=strpath & filename & ".csv", FileFormat:=xlCSV, _
CreateBackup:=False
'If xFile = "" Then
'MsgBox "U folderu nema fajlova", vbInformation, "Obaveštenje"
'Exit Sub
'End If
ActiveWorkbook.Close
Sheets("New fak").Delete
Sheets("Export").Select
Range("H4").Select
lastrow = Cells(Rows.Count, "H").End(xlUp).Row
Range("H4:H" & lastrow).Select
Selection.ClearContents
Range("AW1").Select
Selection.Copy
Range("H4").Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Range("A4").Select
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Range("A4:A" & lastrow).Select
Selection.ClearContents
Range("AW2").Select
Selection.Copy
Range("A4").Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Range("A1").Select
Columns("H:H").Select
Selection.EntireColumn.Hidden = True
Range("C1").Select
Any suggestion how to solve this problem?
-------------------------------------------------------------------------------------------
MOD EDIT: Added code tag.
Attachments
Last edited by a moderator: