A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
Hi,
try this...
Sub ActiveSht_to_CSV_01()
'utf-8
'June 11, 2015
Const sDelim As String = ";" '<< select comma or semicolon
Const sPath As String = "C:\Users\User\Desktop" '<< export on desktop, change path
Dim ws As Worksheet
Set ws = ActiveSheet
Dim r As Long, c As Long, i As Long, j As Long
r = ws.Cells.Find(What:="*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
c = ws.Cells.Find(What:="*", SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column
Dim sFile As String
sFile = sPath & "sample.csv" '<< change file name
Dim obj As Object
Set obj = CreateObject("ADODB.Stream")
obj.Type = 2
obj.Charset = "utf-8"
obj.Open
Dim v() As Variant
ReDim v(1 To c)
For i = 1 To r
For j = 1 To c
v(j) = ws.Cells(i, j).Text 'or Value
Next
obj.WriteText Join(v, sDelim), 1
Next
obj.SaveToFile sFile, 2
MsgBox "done"
End Sub
xxxxxxxxxxxxxxxxxxx
and
(encoding ANSI)
Sub ActiveSht_to_CSV_02()
'ANSI
'June 11, 2015
Const sFile As String = "C:\Users\User\Desktop\sample.csv" '<< export on desktop, change path/name
Dim ws As Worksheet
Set ws = ActiveSheet
Application.ScreenUpdating = False
Application.DisplayAlerts = False
ws.Copy
ActiveWorkbook.SaveAs sFile, FileFormat:=xlCSV, local:=True
ActiveWorkbook.Close False
Application.DisplayAlerts = True
Application.ScreenUpdating = True
MsgBox "done"
End Sub