Skip to content

Instantly share code, notes, and snippets.

@dragonken
Created July 12, 2016 13:40
Show Gist options
  • Save dragonken/790662a03c3ab4754c8eaa7dca588660 to your computer and use it in GitHub Desktop.
Save dragonken/790662a03c3ab4754c8eaa7dca588660 to your computer and use it in GitHub Desktop.
Excel export Selection to UTF-8 CSV file
Sub saveUnicodeCSV()
'Excel export Selection to UTF-8 CSV file
Set oAdoS = CreateObject("ADODB.Stream")
oAdoS.Charset = "UTF-8"
oAdoS.Mode = 3
oAdoS.Type = 2
oAdoS.Open
Dim rng As Range
Dim row As Range
Dim cell As Range
Set rng = Selection
For Each row In rng.Rows
For Each cell In row.Cells
oAdoS.WriteText (",""" & cell.Text & """")
Next cell
oAdoS.WriteText (vbCrLf)
Next row
oAdoS.SaveToFile "export.csv", 2
oAdoS.Close
Set oAdoS = Nothing
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment